Class: LocationsNg::State
- Inherits:
-
Object
- Object
- LocationsNg::State
- Defined in:
- lib/locations_ng/state.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
6 7 8 |
# File 'lib/locations_ng/state.rb', line 6 def all @all_states.map{ |s| {name: s['name'], capital: s['capital']} } end |
.capital(state) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/locations_ng/state.rb', line 23 def capital(state) state_index = @all_states.index{ |s| s['alias'] == format_query(state) } unless state_index.nil? return @all_states[state_index]['capital'] end {message: "No state found for '#{state}'", status: 404} end |
.details(state) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/locations_ng/state.rb', line 10 def details(state) state_index = @all_states.index{ |s| s['alias'] == format_query(state) } if state_index.nil? {message: "No state found for '#{state}'", status: 404} else res = @all_states[state_index] res['cities'] = LocationsNg::City.cities(state) res['lgas'] = LocationsNg::Lga.lgas(state) res end end |