Module: Psgc
- Defined in:
- lib/psgc.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .barangays ⇒ Object
- .cities_municipalities ⇒ Object
- .data_dir ⇒ Object
- .load_data(type) ⇒ Object
- .provinces ⇒ Object
- .regions ⇒ Object
Class Method Details
.barangays ⇒ Object
26 27 28 |
# File 'lib/psgc.rb', line 26 def self. @barangays ||= load_data("barangays") end |
.cities_municipalities ⇒ Object
22 23 24 |
# File 'lib/psgc.rb', line 22 def self.cities_municipalities @cities_municipalities ||= load_data("cities_municipalities") end |
.data_dir ⇒ Object
10 11 12 |
# File 'lib/psgc.rb', line 10 def self.data_dir File.("../../data", __FILE__) end |
.load_data(type) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/psgc.rb', line 30 def self.load_data(type) file_path = File.join(data_dir, "#{type}.json") return [] unless File.exist?(file_path) JSON.parse(File.read(file_path), symbolize_names: true) end |
.provinces ⇒ Object
18 19 20 |
# File 'lib/psgc.rb', line 18 def self.provinces @provinces ||= load_data("provinces") end |
.regions ⇒ Object
14 15 16 |
# File 'lib/psgc.rb', line 14 def self.regions @regions ||= load_data("regions") end |