Module: Indonesia
- Defined in:
- lib/indonesia.rb,
lib/indonesia/finder.rb,
lib/indonesia/version.rb,
lib/generators/indonesia/install_generator.rb
Defined Under Namespace
Modules: Generators
Constant Summary collapse
- VERSION =
'0.6.0'.freeze
Class Method Summary collapse
- .districts ⇒ Object
- .provinces ⇒ Object
- .read_csv(file) ⇒ Object
- .regencies ⇒ Object
- .villages ⇒ Object
Class Method Details
.districts ⇒ Object
17 18 19 20 21 22 |
# 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 ⇒ Object
3 4 5 6 7 8 |
# 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) ⇒ Object
7 8 9 10 |
# 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 ⇒ Object
10 11 12 13 14 15 |
# 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 ⇒ Object
24 25 26 27 28 29 |
# 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 |