Class: IsoCountry

Inherits:
Object
  • Object
show all
Defined in:
lib/iso_countries_plus/iso_country.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#alpha2Object

Returns the value of attribute alpha2.



3
4
5
# File 'lib/iso_countries_plus/iso_country.rb', line 3

def alpha2
  @alpha2
end

#alpha3Object

Returns the value of attribute alpha3.



3
4
5
# File 'lib/iso_countries_plus/iso_country.rb', line 3

def alpha3
  @alpha3
end

#nameObject

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

.allObject



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