Sha256: 291f5a6876c812bbf0bf1189bfd7e1406e32e970468a08c1774061468571baae
Contents?: true
Size: 719 Bytes
Versions: 4
Compression:
Stored size: 719 Bytes
Contents
module ISO3166 ## # Handles building the in memory store of countries data class Data @@cache = nil def initialize(alpha2) @alpha2 = alpha2.to_s.upcase Data.load_cache unless @@cache end def call @@cache[@alpha2] end def self.codes @@codes ||= Data.load_yaml(['countries', 'data', 'countries.yaml']).freeze end private def self.datafile_path(file_array) File.join([File.dirname(__FILE__), '..'] + file_array) end def self.load_yaml(file_array) YAML.load_file(datafile_path(file_array)) end def self.load_cache @@cache ||= Marshal.load(File.binread(datafile_path %w(countries cache countries ))) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
countries-1.2.5 | lib/countries/data.rb |
countries-1.2.4 | lib/countries/data.rb |
countries-1.2.2 | lib/countries/data.rb |
countries-1.2.1 | lib/countries/data.rb |