Class: Decoder::Countries

Inherits:
Object
  • Object
show all
Defined in:
lib/decoder/countries.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCountries

Returns a new instance of Countries.



4
5
6
# File 'lib/decoder/countries.rb', line 4

def initialize
  self.countries = Decoder.locale[Decoder.i18n]
end

Class Method Details

.[](_code) ⇒ Object



26
27
28
# File 'lib/decoder/countries.rb', line 26

def self.[](_code)
  self.new[_code]
end

Instance Method Details

#[](_code) ⇒ Object



20
21
22
23
24
# File 'lib/decoder/countries.rb', line 20

def [](_code)
  _code   = _code.to_s.upcase
  country = countries[_code]
  Decoder::Country.new(:code => _code, :name => country[:name])
end

#countriesObject



16
17
18
# File 'lib/decoder/countries.rb', line 16

def countries
  @countries
end

#countries=(_countries) ⇒ Object



12
13
14
# File 'lib/decoder/countries.rb', line 12

def countries=(_countries)
  @countries = _countries
end

#inspectObject



8
9
10
# File 'lib/decoder/countries.rb', line 8

def inspect
  %{#<#{self.class}>}
end