Class: PSGC::Region
- Inherits:
-
Struct
- Object
- Struct
- PSGC::Region
- Defined in:
- lib/psgc/region.rb
Constant Summary collapse
- REGION_DATA =
File.join(PSGC::DATA_DIR, 'regions.csv')
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(*args) ⇒ Region
constructor
A new instance of Region.
- #provinces ⇒ Object
Constructor Details
#initialize(*args) ⇒ Region
Returns a new instance of Region.
5 6 7 |
# File 'lib/psgc/region.rb', line 5 def initialize(*args) super(*args) end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id
4 5 6 |
# File 'lib/psgc/region.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/psgc/region.rb', line 4 def name @name end |
Class Method Details
.[](id) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/psgc/region.rb', line 16 def [](id) case when id.kind_of?(Fixnum) map_by_num[id] when id.kind_of?(String) map_by_string[id] else raise "\"#{id}\" expected either String or Fixnum (was #{id.class})" end end |
.all ⇒ Object
12 13 14 |
# File 'lib/psgc/region.rb', line 12 def all @@all ||= load_regions end |
Instance Method Details
#code ⇒ Object
45 46 47 |
# File 'lib/psgc/region.rb', line 45 def code "#{id}0000000" end |
#provinces ⇒ Object
49 50 51 |
# File 'lib/psgc/region.rb', line 49 def provinces @provinces ||= load_provinces end |