Module: Iso::Country::InstanceMethods
- Included in:
- Country
- Defined in:
- lib/iso-country/instance.rb
Instance Attribute Summary collapse
-
#alpha2 ⇒ Object
readonly
Returns the value of attribute alpha2.
-
#alpha3 ⇒ Object
readonly
Returns the value of attribute alpha3.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#numeric ⇒ Object
readonly
Returns the value of attribute numeric.
Instance Method Summary collapse
- #__to_s ⇒ Object
- #initialize(alpha2, alpha3, numeric, localizedNames = {}) ⇒ Object
- #inspect ⇒ Object
- #name(locale = :en) ⇒ Object
- #names ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#alpha2 ⇒ Object (readonly)
Returns the value of attribute alpha2.
4 5 6 |
# File 'lib/iso-country/instance.rb', line 4 def alpha2 @alpha2 end |
#alpha3 ⇒ Object (readonly)
Returns the value of attribute alpha3.
4 5 6 |
# File 'lib/iso-country/instance.rb', line 4 def alpha3 @alpha3 end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/iso-country/instance.rb', line 4 def id @id end |
#numeric ⇒ Object (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_s ⇒ Object
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 |
#inspect ⇒ Object
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 |
#names ⇒ Object
14 15 16 |
# File 'lib/iso-country/instance.rb', line 14 def names @localizedNames end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/iso-country/instance.rb', line 28 def to_s name end |