class CountryList::Data

Public Class Methods

countries()
country_codes() click to toggle source
# File lib/country_list/data.rb, line 22
def country_codes
  @@country_codes ||= load_country_codes!
end
datafile_path(file_array) click to toggle source
# File lib/country_list/data.rb, line 18
def datafile_path(file_array)
  File.join([File.dirname(__FILE__)] + file_array)
end
load_cached_countries() click to toggle source
# File lib/country_list/data.rb, line 26
def load_cached_countries
  @@cached_countries ||= load_countries!
end
Also aliased as: countries
load_countries!() click to toggle source
# File lib/country_list/data.rb, line 31
def load_countries!
  Marshal.load(File.binread(datafile_path(%w(cache countries ))))
end
load_country_codes!() click to toggle source
# File lib/country_list/data.rb, line 35
def load_country_codes!
  YAML.load_file(datafile_path(%w(country_data country_codes.yaml)))
end
new(country_code) click to toggle source
# File lib/country_list/data.rb, line 7
def initialize(country_code)
  @country_code = country_code.to_s.upcase
  Data.load_cached_countries unless @@cached_countries
end

Public Instance Methods

call() click to toggle source
# File lib/country_list/data.rb, line 12
def call
  @@cached_countries[@country_code]
end