Class: Nhtsa::ChildSafetySeatInspectionStationLocator::GetByState
- Inherits:
-
Object
- Object
- Nhtsa::ChildSafetySeatInspectionStationLocator::GetByState
- Defined in:
- lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_state.rb
Instance Method Summary collapse
-
#initialize(state_abbreviation, filters = {spanish: false, cpsweek: false}) ⇒ GetByState
constructor
A new instance of GetByState.
- #inspection_stations ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(state_abbreviation, filters = {spanish: false, cpsweek: false}) ⇒ GetByState
Returns a new instance of GetByState.
4 5 6 7 |
# File 'lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_state.rb', line 4 def initialize(state_abbreviation, filters = {spanish: false, cpsweek: false}) @state_abbreviation = state_abbreviation @filters = filters end |
Instance Method Details
#inspection_stations ⇒ Object
21 22 23 |
# File 'lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_state.rb', line 21 def inspection_stations JSON.parse(open(url).read)["Results"] end |
#url ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_state.rb', line 9 def url if @filters[:spanish] && @filters[:cpsweek] BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + CPS_WEEK + SPANISH + DEFAULT_PARAMS elsif @filters[:spanish] BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + SPANISH + DEFAULT_PARAMS elsif @filters[:cpsweek] BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + CPS_WEEK + DEFAULT_PARAMS else BASE_URI + END_POINT + "/state/#{@state_abbreviation}" + DEFAULT_PARAMS end end |