Class: ThProvince::Geography
- Inherits:
-
Object
- Object
- ThProvince::Geography
- Defined in:
- lib/th_province/geography.rb
Class Method Summary collapse
Instance Method Summary collapse
- #amphurs ⇒ Object
- #as_json ⇒ Object
- #districts ⇒ Object
-
#initialize(json) ⇒ Geography
constructor
A new instance of Geography.
- #provinces ⇒ Object
Constructor Details
#initialize(json) ⇒ Geography
Returns a new instance of Geography.
20 21 22 |
# File 'lib/th_province/geography.rb', line 20 def initialize(json) @json = json end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/th_province/geography.rb', line 10 def self.all @@data.values end |
.data ⇒ Object
6 7 8 |
# File 'lib/th_province/geography.rb', line 6 def self.data @@data end |
.find(id) ⇒ Object
14 15 16 17 18 |
# File 'lib/th_province/geography.rb', line 14 def self.find(id) json = @@data[id.to_s] return self.new(@@data[id.to_s]) if !json.nil? nil end |
Instance Method Details
#amphurs ⇒ Object
32 33 34 |
# File 'lib/th_province/geography.rb', line 32 def amphurs ThProvince::Amphur.amphur_with_geography_id(@json["id"]) end |
#as_json ⇒ Object
24 25 26 |
# File 'lib/th_province/geography.rb', line 24 def as_json @json end |
#districts ⇒ Object
36 37 38 |
# File 'lib/th_province/geography.rb', line 36 def districts ThProvince::District.districts_with_geography_id(@json["id"]) end |
#provinces ⇒ Object
28 29 30 |
# File 'lib/th_province/geography.rb', line 28 def provinces ThProvince::Province.provinces_with_geography_id(@json["id"]) end |