Class: WhereStreets

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/where_streets.rb,
lib/where_streets/version.rb

Constant Summary collapse

FILE =
MessagePack.unpack(File.read(File.expand_path("../pcas.mp", __dir__))).freeze
VERSION =
"0.5.1".freeze

Instance Method Summary collapse

Instance Method Details

#find_cities(province) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/where_streets.rb', line 22

def find_cities(province)
  return [] if province.blank?

  handle_error do
    FILE[province.to_s].keys
  end
end

#find_counties(province, city) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/where_streets.rb', line 30

def find_counties(province, city)
  return [] if [province, city].any? { |i| i.blank? }

  handle_error do
    FILE[province.to_s][city.to_s].keys
  end
end

#find_provincesObject



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

def find_provinces
  FILE.keys
end

#find_towns(province, city, county) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/where_streets.rb', line 38

def find_towns(province, city, county)
  return [] if [province, city, county].any? { |i| i.blank? }

  handle_error do
    FILE[province.to_s][city.to_s][county.to_s]
  end
end