module Indonesia
Constants
- VERSION
Public Class Methods
districts()
click to toggle source
# File lib/indonesia/finder.rb, line 17 def self.districts @districts ||= begin data = read_csv('districts') data.map { |r| { id: r[0].to_i, regency_id: r[1].to_i, name: r[2] } } end end
provinces()
click to toggle source
# File lib/indonesia/finder.rb, line 3 def self.provinces @provinces ||= begin data = read_csv('provinces') data.map { |r| { id: r[0].to_i, name: r[1] } } end end
read_csv(file)
click to toggle source
# File lib/indonesia.rb, line 7 def self.read_csv(file) file_path = File.join(File.dirname(__FILE__), 'data/', "#{file}.csv") CSV.read(file_path) end
regencies()
click to toggle source
# File lib/indonesia/finder.rb, line 10 def self.regencies @regencies ||= begin data = read_csv('regencies') data.map { |r| { id: r[0].to_i, province_id: r[1].to_i, name: r[2] } } end end
villages()
click to toggle source
# File lib/indonesia/finder.rb, line 24 def self.villages @villages ||= begin data = read_csv('villages') data.map { |r| { id: r[0].to_i, district_id: r[1].to_i, name: r[2] } } end end