Sha256: 77482292f73fe3ca00f7f04333d2025cf5b13ed2c2ca7b8a99ed4505c0b8beff
Contents?: true
Size: 632 Bytes
Versions: 1
Compression:
Stored size: 632 Bytes
Contents
require 'active_support' class Country < Struct.new(:name, :country_code, :char_2_code, :area_code) cattr_accessor :all def self.load return @@all if @@all.present? data_file = File.join(File.dirname(__FILE__), '..', 'data', 'countries.yml') @@all = {} YAML.load(File.read(data_file)).each_pair do |key, c| @@all[key] = Country.new(c[:name], c[:country_code], c[:char_2_code], c[:area_code]) end @@all end def to_s name end def self.find_by_country_code(code) @@all[code] end def country_code_regexp Regexp.new("^[+]#{country_code}") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
phone-0.9.9 | lib/country.rb |