Class: LocationsNg::City
- Inherits:
-
Object
- Object
- LocationsNg::City
- Defined in:
- lib/locations_ng/city.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
3 4 5 |
# File 'lib/locations_ng/city.rb', line 3 def self.all load_cities end |
.cities(state) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/locations_ng/city.rb', line 7 def self.cities(state) state = state.downcase.gsub(' ', '_') all_cities = load_cities if state == 'federal_capital_territory' state = 'fct' end city_index = all_cities.index{|c| c['alias'] == state} if city_index.nil? {message: "No cities found for '#{state}'", status: 404} else all_cities[city_index]['cities'] end end |