class Nhtsa::ChildSafetySeatInspectionStationLocator::GetByState

Public Class Methods

new(state_abbreviation, filters = {spanish: false, cpsweek: false}) click to toggle source
# 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

Public Instance Methods

inspection_stations() click to toggle source
# 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() click to toggle source
# 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