class Country

Constants

ATTR_READERS

Attributes

data[R]

Public Class Methods

[](country_code) click to toggle source
# File lib/country_list/country.rb, line 57
def [](country_code)
  country = new(country_code)
  (country && country.valid?) ? country : nil
end
all() click to toggle source

Returns big array with all countries

# File lib/country_list/country.rb, line 53
def all
  CountryList::Data.countries.map{ |country_code, data| Country.new(country_code) }
end
country_codes() click to toggle source
# File lib/country_list/country.rb, line 62
def country_codes
  CountryList::Data.country_codes
end
new(country_code) click to toggle source
# File lib/country_list/country.rb, line 22
def initialize(country_code)
  @data = CountryList::Data.new(country_code).call
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/country_list/country.rb, line 26
def <=>(other)
  to_s <=> other.to_s
end
==(other) click to toggle source
# File lib/country_list/country.rb, line 30
def ==(other)
  @data == other.data
end
eu_member?() click to toggle source
# File lib/country_list/country.rb, line 42
def eu_member?
  @data && @data['eu_member'].nil? ? false : @data['eu_member']
end
in_europe?() click to toggle source
# File lib/country_list/country.rb, line 46
def in_europe?
  @data && @data['continent'].nil? ? false : @data['continent'] == 'Europe'
end
to_s() click to toggle source
# File lib/country_list/country.rb, line 38
def to_s
  name
end
valid?() click to toggle source
# File lib/country_list/country.rb, line 34
def valid?
  !(@data.nil? || @data.empty?)
end