Class: Iarea::Prefecture
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Iarea::Prefecture
- Defined in:
- lib/iarea/prefecture.rb
Overview
Prefecture
Constant Summary collapse
- @@prefectures =
{}
Class Method Summary collapse
-
.all ⇒ Object
All prefectures.
-
.find(id) ⇒ Object
Find a prefecture by
id
.
Instance Method Summary collapse
-
#areas ⇒ Object
Areas in the prefecture.
-
#zone ⇒ Object
Zone of the prefecture.
Class Method Details
.all ⇒ Object
All prefectures
29 30 31 |
# File 'lib/iarea/prefecture.rb', line 29 def all DB['prefecture_ids'].map{ |id| find(id) } end |
.find(id) ⇒ Object
Find a prefecture by id
18 19 20 21 22 23 24 25 26 |
# File 'lib/iarea/prefecture.rb', line 18 def find(id) if prefecture = @@prefectures[id.to_i] prefecture elsif prefecture_data = DB['prefecture'][id.to_i] @@prefectures[id.to_i] ||= new(prefecture_data) else nil end end |