Module: Psgc

Defined in:
lib/psgc.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.barangaysObject



26
27
28
# File 'lib/psgc.rb', line 26

def self.barangays
  @barangays ||= load_data("barangays")
end

.cities_municipalitiesObject



22
23
24
# File 'lib/psgc.rb', line 22

def self.cities_municipalities
  @cities_municipalities ||= load_data("cities_municipalities")
end

.data_dirObject



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

def self.data_dir
  File.expand_path("../../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

.provincesObject



18
19
20
# File 'lib/psgc.rb', line 18

def self.provinces
  @provinces ||= load_data("provinces")
end

.regionsObject



14
15
16
# File 'lib/psgc.rb', line 14

def self.regions
  @regions ||= load_data("regions")
end