Class: PhoneCountry
- Inherits:
-
Struct
- Object
- Struct
- PhoneCountry
- Defined in:
- lib/phone_country.rb
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.
-
#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
#area_code ⇒ Object
Returns the value of attribute area_code
2 3 4 |
# File 'lib/phone_country.rb', line 2 def area_code @area_code end |
#char_2_code ⇒ Object
Returns the value of attribute char_2_code
2 3 4 |
# File 'lib/phone_country.rb', line 2 def char_2_code @char_2_code end |
#country_code ⇒ Object
Returns the value of attribute country_code
2 3 4 |
# File 'lib/phone_country.rb', line 2 def country_code @country_code end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/phone_country.rb', line 2 def name @name end |
Class Method Details
.find_by_country_code(code) ⇒ Object
21 22 23 |
# File 'lib/phone_country.rb', line 21 def self.find_by_country_code(code) @@all[code] end |
.load ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/phone_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] = PhoneCountry.new(c[:name], c[:country_code], c[:char_2_code], c[:area_code]) end @@all end |
Instance Method Details
#country_code_regexp ⇒ Object
25 26 27 |
# File 'lib/phone_country.rb', line 25 def country_code_regexp Regexp.new("^[+]#{country_code}") end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/phone_country.rb', line 17 def to_s name end |