module Country

Public Instance Methods

all() click to toggle source
# File lib/country.rb, line 5
def all
  COUNTRIES.values
end
alpha2(country_name='') click to toggle source
# File lib/country.rb, line 21
def alpha2(country_name='')
   country= all.select{|country| country["name"].upcase.eql?(country_name.upcase)}.first
   country["alpha2"] if country
end
names() click to toggle source
# File lib/country.rb, line 9
def names
 all.map{|country| country["name"]}
end
with_postal_code() click to toggle source
# File lib/country.rb, line 13
def with_postal_code
  Hash[all.map{|country| [country['alpha2'],country['name']] if country["postal_code"]}.compact]
end
without_postal_code() click to toggle source
# File lib/country.rb, line 17
def without_postal_code
  Hash[all.map{|country| [country['alpha2'],country['name']] unless country["postal_code"]}.compact]
end