Class: CountriesData::Country

Inherits:
Object
  • Object
show all
Defined in:
lib/countries_data/country.rb

Constant Summary collapse

PHONE_MIN_LENGTH =
5
PHONE_MAX_LENGTH =
14

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#emojiObject (readonly)

Returns the value of attribute emoji.



4
5
6
# File 'lib/countries_data/country.rb', line 4

def emoji
  @emoji
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/countries_data/country.rb', line 3

def id
  @id
end

#namesObject (readonly)

Returns the value of attribute names.



5
6
7
# File 'lib/countries_data/country.rb', line 5

def names
  @names
end

#nationalitiesObject (readonly)

Returns the value of attribute nationalities.



7
8
9
# File 'lib/countries_data/country.rb', line 7

def nationalities
  @nationalities
end

#phone_codeObject (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_lengthObject



30
31
32
# File 'lib/countries_data/country.rb', line 30

def phone_max_length
  @phone_max_length || PHONE_MAX_LENGTH
end

#phone_min_lengthObject



26
27
28
# File 'lib/countries_data/country.rb', line 26

def phone_min_length
  @phone_min_length || PHONE_MIN_LENGTH
end