Class: LocationsNg::City

Inherits:
Object
  • Object
show all
Defined in:
lib/locations_ng/city.rb

Class Method Summary collapse

Class Method Details

.allObject



6
7
8
# File 'lib/locations_ng/city.rb', line 6

def all
  @all_cities
end

.cities(state) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/locations_ng/city.rb', line 10

def cities(state)
  state_query = state_query(state.downcase.tr(' ', '_'))
  city_index = @all_cities.index{ |c| c['alias'] == state_query }

  unless city_index.nil?
    return @all_cities[city_index]['cities']
  end

  {message: "No cities found for '#{state}'", status: 404}
end