Module: RegionLookup::Loader

Defined in:
lib/region_lookup/loader.rb

Constant Summary collapse

DATA_PATH =
File.expand_path("../../data", __dir__)

Class Method Summary collapse

Class Method Details

.cities(country_code) ⇒ Object



17
18
19
# File 'lib/region_lookup/loader.rb', line 17

def self.cities(country_code)
  load_yaml("cities/#{country_code}.yml")
end

.countriesObject



9
10
11
# File 'lib/region_lookup/loader.rb', line 9

def self.countries
  load_yaml("countries.yml")["country"]
end

.load_yaml(file) ⇒ Object



5
6
7
# File 'lib/region_lookup/loader.rb', line 5

def self.load_yaml(file)
  YAML.load_file(File.join(DATA_PATH, file))
end

.states(country_code) ⇒ Object



13
14
15
# File 'lib/region_lookup/loader.rb', line 13

def self.states(country_code)
  load_yaml("states/#{country_code}.yml")
end