class LocationsNg::City

Public Class Methods

all() click to toggle source
# File lib/locations_ng/city.rb, line 6
def all
  @all_cities
end
cities(state) click to toggle source
# 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

Private Class Methods

state_query(state) click to toggle source
# File lib/locations_ng/city.rb, line 23
def state_query(state)
  state == 'federal_capital_territory' ? 'fct' : state
end