Class: Carmen::Country

Inherits:
Region
  • Object
show all
Extended by:
Querying, SingleForwardable
Defined in:
lib/carmen/country.rb

Instance Attribute Summary collapse

Attributes inherited from Region

#parent, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Querying

coded, named

Methods inherited from Region

#<=>, #name, #path, #reset!, #subregion_class, #subregion_data_path, #subregions, #subregions?, #to_s

Constructor Details

#initialize(data = {}, parent = nil) ⇒ Country

Returns a new instance of Country.



16
17
18
19
20
21
# File 'lib/carmen/country.rb', line 16

def initialize(data={}, parent=nil)
  @alpha_2_code = data['alpha_2_code']
  @alpha_3_code = data['alpha_3_code']
  @numeric_code = data['numeric_code']
  super
end

Instance Attribute Details

#alpha_2_codeObject (readonly)

Returns the value of attribute alpha_2_code.



12
13
14
# File 'lib/carmen/country.rb', line 12

def alpha_2_code
  @alpha_2_code
end

#alpha_3_codeObject (readonly)

Returns the value of attribute alpha_3_code.



13
14
15
# File 'lib/carmen/country.rb', line 13

def alpha_3_code
  @alpha_3_code
end

#numeric_codeObject (readonly)

Returns the value of attribute numeric_code.



14
15
16
# File 'lib/carmen/country.rb', line 14

def numeric_code
  @numeric_code
end

Class Method Details

.allObject



31
32
33
# File 'lib/carmen/country.rb', line 31

def self.all
  World.instance.subregions
end

.query_collectionObject



35
36
37
# File 'lib/carmen/country.rb', line 35

def self.query_collection
  all
end

Instance Method Details

#codeObject



55
56
57
# File 'lib/carmen/country.rb', line 55

def code
  alpha_2_code
end

#common_nameObject



23
24
25
# File 'lib/carmen/country.rb', line 23

def common_name
  Carmen.i18n_backend.translate(path('common_name'))
end

#inspectObject



51
52
53
# File 'lib/carmen/country.rb', line 51

def inspect
  %(<##{self.class} name="#{name}">)
end

#official_nameObject



27
28
29
# File 'lib/carmen/country.rb', line 27

def official_name
  Carmen.i18n_backend.translate(path('official_name'))
end

#to_hashObject



59
60
61
# File 'lib/carmen/country.rb', line 59

def to_hash
  super.merge({ alpha_2_code: alpha_2_code, alpha_3_code: alpha_3_code, numeric_code: numeric_code })
end