module Ruuaby
Constants
- VERSION
Public Class Methods
configure() { |self| ... }
click to toggle source
# File lib/ruuaby/configuration.rb, line 12 def self.configure yield self end
countries()
click to toggle source
# File lib/ruuaby.rb, line 9 def countries @@countries end
data_path()
click to toggle source
# File lib/ruuaby/configuration.rb, line 8 def self.data_path @@data_path end
data_path=(data_path)
click to toggle source
# File lib/ruuaby/configuration.rb, line 4 def self.data_path=(data_path) @@data_path = data_path end
each() { |country_name, region_name, area_name, city_name| ... }
click to toggle source
# File lib/ruuaby.rb, line 20 def each(&block) @@countries.each do |country_name, regions| regions.each do |region_name, areas| areas.each do |area_name, cities| cities.each do |city_name, city| yield(country_name, region_name, area_name, city_name) if block end end end end end
load_data()
click to toggle source
# File lib/ruuaby.rb, line 13 def load_data @@countries ||= begin data = File.read(path_for_file) Oj.load(data) end end
Private Class Methods
path_for_file()
click to toggle source
# File lib/ruuaby.rb, line 33 def path_for_file raise "Data path not found: #{data_path}" unless Dir.exists?(data_path) File.join(data_path, "data.json") end