class ThProvince::District

Public Class Methods

all() click to toggle source
# File lib/th_province/district.rb, line 12
def self.all
  @@data.values
end
data() click to toggle source
# File lib/th_province/district.rb, line 8
def self.data
  @@data
end
districts_with_amphur_id(amphur_id) click to toggle source
# File lib/th_province/district.rb, line 52
def self.districts_with_amphur_id(amphur_id)
  arr = @@amphur_id_to_data[amphur_id]
  arr.map{|a| self.new(a)}
end
districts_with_geography_id(geography_id) click to toggle source
# File lib/th_province/district.rb, line 42
def self.districts_with_geography_id(geography_id)
  arr = @@geography_id_to_data[geography_id]
  arr.map{|a| self.new(a)}
end
districts_with_province_id(province_id) click to toggle source
# File lib/th_province/district.rb, line 47
def self.districts_with_province_id(province_id)
  arr = @@province_id_to_data[province_id]
  arr.map{|a| self.new(a)}
end
find(id) click to toggle source
# File lib/th_province/district.rb, line 16
def self.find(id)
  json = @@data[id.to_s]
  return self.new(@@data[id.to_s]) if !json.nil?
  nil
end
new(json) click to toggle source
# File lib/th_province/district.rb, line 22
def initialize(json)
  @json = json
end

Public Instance Methods

amphur() click to toggle source
# File lib/th_province/district.rb, line 38
def amphur
  ThProvince::Amphur.find(@json["amphur_id"])
end
as_json() click to toggle source
# File lib/th_province/district.rb, line 26
def as_json
  @json
end
geography() click to toggle source
# File lib/th_province/district.rb, line 30
def geography
  ThProvince::Geography.find(@json["geography_id"])
end
province() click to toggle source
# File lib/th_province/district.rb, line 34
def province
  ThProvince::Province.find(@json["province_id"])
end