class AppStoreReviews::Store

Attributes

id[R]

Public Class Methods

new(store_id_or_country) click to toggle source
# File lib/app_store_reviews/store.rb, line 5
def initialize(store_id_or_country)
  if store_id_or_country.is_a?(Integer)
    @id = store_id_or_country
  elsif store_id_or_country.is_a?(String)
    @id = resolve_store_id(store_id_or_country)
  end
end

Private Instance Methods

resolve_store_id(country) click to toggle source
# File lib/app_store_reviews/store.rb, line 15
def resolve_store_id(country)
  store_data = AppStoreReviews::STORES.detect do |store|
    store[:country] == country
  end
  raise UnknownStore.new("Unknown store for country '#{country}'") unless store_data
  store_data[:id]
end