Class: IsoCountry
- Inherits:
-
Object
- Object
- IsoCountry
- Defined in:
- lib/iso_countries_plus/iso_country.rb
Instance Attribute Summary collapse
-
#alpha2 ⇒ Object
Returns the value of attribute alpha2.
-
#alpha3 ⇒ Object
Returns the value of attribute alpha3.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .all ⇒ Object
- .find_by_alpha2(code) ⇒ Object (also: alpha2)
- .find_by_alpha3(code) ⇒ Object (also: alpha3)
- .find_by_name(name) ⇒ Object (also: name)
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ IsoCountry
constructor
A new instance of IsoCountry.
Constructor Details
#initialize(data = {}) ⇒ IsoCountry
Returns a new instance of IsoCountry.
5 6 7 8 9 10 11 |
# File 'lib/iso_countries_plus/iso_country.rb', line 5 def initialize(data={}) if data and !data.nil? data.each do |k, v| send("#{k}=", v) if self.respond_to? "#{k}=" end end end |
Instance Attribute Details
#alpha2 ⇒ Object
Returns the value of attribute alpha2.
3 4 5 |
# File 'lib/iso_countries_plus/iso_country.rb', line 3 def alpha2 @alpha2 end |
#alpha3 ⇒ Object
Returns the value of attribute alpha3.
3 4 5 |
# File 'lib/iso_countries_plus/iso_country.rb', line 3 def alpha3 @alpha3 end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/iso_countries_plus/iso_country.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/iso_countries_plus/iso_country.rb', line 15 def all COUNTRIES[:alpha2].values end |
.find_by_alpha2(code) ⇒ Object Also known as: alpha2
24 25 26 |
# File 'lib/iso_countries_plus/iso_country.rb', line 24 def find_by_alpha2(code) COUNTRIES[:alpha2][code.to_s.upcase] end |
.find_by_alpha3(code) ⇒ Object Also known as: alpha3
29 30 31 |
# File 'lib/iso_countries_plus/iso_country.rb', line 29 def find_by_alpha3(code) COUNTRIES[:alpha3][code.to_s.upcase] end |
.find_by_name(name) ⇒ Object Also known as: name
19 20 21 |
# File 'lib/iso_countries_plus/iso_country.rb', line 19 def find_by_name(name) COUNTRIES[:name][name] end |