Class: Decoder::Countries
- Inherits:
-
Object
- Object
- Decoder::Countries
- Defined in:
- lib/countries/countries.rb
Instance Attribute Summary collapse
-
#countries ⇒ Object
Returns the value of attribute countries.
Class Method Summary collapse
Instance Method Summary collapse
- #[](_code) ⇒ Object
-
#initialize ⇒ Countries
constructor
A new instance of Countries.
- #load_yaml ⇒ Object
- #yaml_file_name ⇒ Object
Constructor Details
#initialize ⇒ Countries
Returns a new instance of Countries.
5 6 7 |
# File 'lib/countries/countries.rb', line 5 def initialize self.load_yaml end |
Instance Attribute Details
#countries ⇒ Object
Returns the value of attribute countries.
3 4 5 |
# File 'lib/countries/countries.rb', line 3 def countries @countries end |
Class Method Details
.[](_code) ⇒ Object
23 24 25 |
# File 'lib/countries/countries.rb', line 23 def self.[](_code) self.new[_code] end |
Instance Method Details
#[](_code) ⇒ Object
17 18 19 20 21 |
# File 'lib/countries/countries.rb', line 17 def [](_code) _code = _code.to_s.upcase country = countries[_code] Decoder::Country.new(:code => _code, :name => country) end |
#load_yaml ⇒ Object
9 10 11 |
# File 'lib/countries/countries.rb', line 9 def load_yaml self.countries = YAML.load_file(yaml_file_name) end |