class Phoner::Country
Public Class Methods
find_by_country_code(code)
click to toggle source
# File lib/country.rb, line 21 def self.find_by_country_code(code) @@all[code] end
find_by_country_isocode(isocode)
click to toggle source
# File lib/country.rb, line 25 def self.find_by_country_isocode(isocode) if country = @@all.detect{|c|c[1].char_3_code.downcase == isocode} country[1] end end
load()
click to toggle source
# File lib/country.rb, line 5 def self.load return @@all if @@all.present? data_file = File.join(File.dirname(__FILE__), '..', 'data', 'phone_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[:char_3_code], c[:area_code]) end @@all end
Public Instance Methods
country_code_regexp()
click to toggle source
# File lib/country.rb, line 31 def country_code_regexp Regexp.new("^[+]#{country_code}") end
to_s()
click to toggle source
# File lib/country.rb, line 17 def to_s name end