Module: Iso::Country::InstanceMethods

Included in:
Country
Defined in:
lib/iso-country/instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#alpha2Object (readonly)

Returns the value of attribute alpha2.



4
5
6
# File 'lib/iso-country/instance.rb', line 4

def alpha2
  @alpha2
end

#alpha3Object (readonly)

Returns the value of attribute alpha3.



4
5
6
# File 'lib/iso-country/instance.rb', line 4

def alpha3
  @alpha3
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/iso-country/instance.rb', line 4

def id
  @id
end

#numericObject (readonly)

Returns the value of attribute numeric.



4
5
6
# File 'lib/iso-country/instance.rb', line 4

def numeric
  @numeric
end

Instance Method Details

#__to_sObject



26
# File 'lib/iso-country/instance.rb', line 26

alias :__to_s :to_s

#initialize(alpha2, alpha3, numeric, localizedNames = {}) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/iso-country/instance.rb', line 6

def initialize(alpha2, alpha3, numeric, localizedNames = {})
  @id = alpha2.downcase.to_sym
  @alpha2 = alpha2
  @alpha3 = alpha3
  @numeric = numeric.to_i
  @localizedNames = localizedNames
end

#inspectObject



32
33
34
# File 'lib/iso-country/instance.rb', line 32

def inspect
  __to_s()
end

#name(locale = :en) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/iso-country/instance.rb', line 18

def name(locale = :en)
  if @localizedNames.empty?
    "#{alpha3} (#{"%03d" % numeric})"
  else
    @localizedNames[locale]
  end
end

#namesObject



14
15
16
# File 'lib/iso-country/instance.rb', line 14

def names
  @localizedNames
end

#to_sObject



28
29
30
# File 'lib/iso-country/instance.rb', line 28

def to_s
  name
end