Class: Iarea::Zone
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Iarea::Zone
- Defined in:
- lib/iarea/zone.rb
Constant Summary collapse
- @@zones =
{}
Class Method Summary collapse
-
.all ⇒ Object
All zones.
-
.find(id) ⇒ Object
Find a zone by
id
.
Instance Method Summary collapse
-
#areas ⇒ Object
Areas in the zone.
-
#prefectures ⇒ Object
Prefectures in the zone.
Class Method Details
.all ⇒ Object
All zones
28 29 30 |
# File 'lib/iarea/zone.rb', line 28 def all DB['zone_ids'].map{|id| Zone.find id} end |
.find(id) ⇒ Object
Find a zone by id
17 18 19 20 21 22 23 24 25 |
# File 'lib/iarea/zone.rb', line 17 def find(id) if zone = @@zones[id.to_i] zone elsif zone_data = DB['zone'][id.to_i] @@zones[id.to_i] ||= new(zone_data) else nil end end |
Instance Method Details
#areas ⇒ Object
Areas in the zone
11 12 13 |
# File 'lib/iarea/zone.rb', line 11 def areas self.areacodes.map {|areacode| Area.find areacode} end |
#prefectures ⇒ Object
Prefectures in the zone
6 7 8 |
# File 'lib/iarea/zone.rb', line 6 def prefectures self.prefecture_ids.map {|prefecture_id| Prefecture.find prefecture_id} end |