Class: ThProvince::Geography

Inherits:
Object
  • Object
show all
Defined in:
lib/th_province/geography.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.allObject



10
11
12
# File 'lib/th_province/geography.rb', line 10

def self.all
  @@data.values
end

.dataObject



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

#amphursObject



32
33
34
# File 'lib/th_province/geography.rb', line 32

def amphurs
  ThProvince::Amphur.amphur_with_geography_id(@json["id"])
end

#as_jsonObject



24
25
26
# File 'lib/th_province/geography.rb', line 24

def as_json
  @json
end

#districtsObject



36
37
38
# File 'lib/th_province/geography.rb', line 36

def districts
  ThProvince::District.districts_with_geography_id(@json["id"])
end

#provincesObject



28
29
30
# File 'lib/th_province/geography.rb', line 28

def provinces
  ThProvince::Province.provinces_with_geography_id(@json["id"])
end