class Gwitch::Country

Constants

InvaildAlpha2CodeError

Public Class Methods

all() click to toggle source

All avaliable countries

# File lib/gwitch/country.rb, line 12
def all
  countries = ISO3166::Country.all.map do |country|
    Country.new(country.alpha2)
  end

  countries.select{ |country| country.avaliable? }
end
new(alpha2) click to toggle source
# File lib/gwitch/country.rb, line 21
def initialize(alpha2)
  @country = ISO3166::Country[alpha2]
  raise InvaildAlpha2CodeError unless @country
end

Public Instance Methods

alpha2() click to toggle source
# File lib/gwitch/country.rb, line 26
def alpha2
  @country.alpha2
end
avaliable?() click to toggle source
# File lib/gwitch/country.rb, line 38
def avaliable?
  # An americas game
  nsuid = '70010000000141'
  
  !Game.price(alpha2, nsuid).nil?
end
currency() click to toggle source
# File lib/gwitch/country.rb, line 34
def currency
  @country.currency_code
end
region() click to toggle source
# File lib/gwitch/country.rb, line 30
def region
  @country.region
end