class ISO3166::Data

Handles building the in memory store of countries data
#

def self.codes

def self.codes
  @@codes ||= Data.load_yaml(['data', 'countries.yaml']).freeze
end

def self.datafile_path(file_array)

def self.datafile_path(file_array)
  File.join([File.dirname(__FILE__), '..'] + file_array)
end

def self.load_cache

def self.load_cache
  @@cache ||= Marshal.load(File.binread(datafile_path %w(cache countries )))
end

def self.load_yaml(file_array)

def self.load_yaml(file_array)
  YAML.load_file(datafile_path(file_array))
end

def call

def call
   @@cache[@alpha2]
end

def initialize(alpha2)

def initialize(alpha2)
  @alpha2 = alpha2.to_s.upcase
  Data.load_cache unless @@cache
end