Class: Locale::Info::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/locale/info/region.rb

Overview

This class models out a region/country from the ISO 3166 standard for region codes. In ISO3166, it’s called “Country” but Ruby/Locale the word “Region” instead.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, name) ⇒ Region

code

The 2 or 3 digit ISO 3166 region code.

name

The name of the region.



25
26
27
28
# File 'lib/locale/info/region.rb', line 25

def initialize(code, name)
  @code = code
  @name = name
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



21
22
23
# File 'lib/locale/info/region.rb', line 21

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/locale/info/region.rb', line 21

def name
  @name
end

Instance Method Details

#iso_region?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/locale/info/region.rb', line 30

def iso_region?
  @@regions[code] != nil
end

#to_sObject



34
35
36
# File 'lib/locale/info/region.rb', line 34

def to_s
  "#{code}"
end