Class: CountriesData::Country
- Inherits:
-
Object
- Object
- CountriesData::Country
- Defined in:
- lib/countries_data/country.rb
Constant Summary collapse
- PHONE_MIN_LENGTH =
5- PHONE_MAX_LENGTH =
14
Instance Attribute Summary collapse
-
#emoji ⇒ Object
readonly
Returns the value of attribute emoji.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#nationalities ⇒ Object
readonly
Returns the value of attribute nationalities.
-
#phone_code ⇒ Object
readonly
Returns the value of attribute phone_code.
Instance Method Summary collapse
-
#initialize(data) ⇒ Country
constructor
A new instance of Country.
- #name(locale) ⇒ Object
- #nationality(locale) ⇒ Object
- #phone_max_length ⇒ Object
- #phone_min_length ⇒ Object
Constructor Details
#initialize(data) ⇒ Country
Returns a new instance of Country.
12 13 14 15 16 17 18 19 20 |
# File 'lib/countries_data/country.rb', line 12 def initialize(data) @id = data[:id] @emoji = data[:emoji] @names = data[:names] @phone_code = data[:phone_code] @phone_min_length = data[:phone_min_length] @phone_max_length = data[:phone_max_length] @nationalities = data[:nationalities] end |
Instance Attribute Details
#emoji ⇒ Object (readonly)
Returns the value of attribute emoji.
4 5 6 |
# File 'lib/countries_data/country.rb', line 4 def emoji @emoji end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/countries_data/country.rb', line 3 def id @id end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
5 6 7 |
# File 'lib/countries_data/country.rb', line 5 def names @names end |
#nationalities ⇒ Object (readonly)
Returns the value of attribute nationalities.
7 8 9 |
# File 'lib/countries_data/country.rb', line 7 def nationalities @nationalities end |
#phone_code ⇒ Object (readonly)
Returns the value of attribute phone_code.
6 7 8 |
# File 'lib/countries_data/country.rb', line 6 def phone_code @phone_code end |
Instance Method Details
#name(locale) ⇒ Object
22 23 24 |
# File 'lib/countries_data/country.rb', line 22 def name(locale) names[locale.to_sym] end |
#nationality(locale) ⇒ Object
34 35 36 |
# File 'lib/countries_data/country.rb', line 34 def nationality(locale) nationalities[locale.to_sym] end |
#phone_max_length ⇒ Object
30 31 32 |
# File 'lib/countries_data/country.rb', line 30 def phone_max_length @phone_max_length || PHONE_MAX_LENGTH end |
#phone_min_length ⇒ Object
26 27 28 |
# File 'lib/countries_data/country.rb', line 26 def phone_min_length @phone_min_length || PHONE_MIN_LENGTH end |