Class: Phoner::Country
Instance Attribute Summary collapse
-
#area_code ⇒ Object
Returns the value of attribute area_code.
-
#char_2_code ⇒ Object
Returns the value of attribute char_2_code.
-
#char_3_code ⇒ Object
Returns the value of attribute char_3_code.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
permalink #area_code ⇒ Object
Returns the value of attribute area_code
2 3 4 |
# File 'lib/country.rb', line 2 def area_code @area_code end |
permalink #char_2_code ⇒ Object
Returns the value of attribute char_2_code
2 3 4 |
# File 'lib/country.rb', line 2 def char_2_code @char_2_code end |
permalink #char_3_code ⇒ Object
Returns the value of attribute char_3_code
2 3 4 |
# File 'lib/country.rb', line 2 def char_3_code @char_3_code end |
Class Method Details
permalink .find_by_country_code(code) ⇒ Object
[View source]
21 22 23 |
# File 'lib/country.rb', line 21 def self.find_by_country_code(code) @@all[code] end |
permalink .find_by_country_isocode(isocode) ⇒ Object
[View source]
25 26 27 28 29 |
# 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 |
permalink .load ⇒ Object
[View source]
5 6 7 8 9 10 11 12 13 14 15 |
# 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 |
Instance Method Details
permalink #country_code_regexp ⇒ Object
[View source]
31 32 33 |
# File 'lib/country.rb', line 31 def country_code_regexp Regexp.new("^[+]#{country_code}") end |