class Nhtsa::ChildSafetySeatInspectionStationLocator::GetByZipCode
Public Class Methods
new(zip_code, filters = {:spanish => false, :cpsweek => false})
click to toggle source
# File lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_zip_code.rb, line 4 def initialize(zip_code, filters = {:spanish => false, :cpsweek => false}) @zip_code = zip_code @filters = filters end
Public Instance Methods
inspection_stations()
click to toggle source
# File lib/nhtsa/child_safety_seat_inspection_station_locator/get_by_zip_code.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_zip_code.rb, line 9 def url if @filters[:spanish] && @filters[:cpsweek] "#{BASE_URI}#{END_POINT}/zip/#{@zip_code}#{CPS_WEEK}#{SPANISH}#{DEFAULT_PARAMS}" elsif @filters[:spanish] "#{BASE_URI}#{END_POINT}/zip/#{@zip_code}#{SPANISH}#{DEFAULT_PARAMS}" elsif @filters[:cpsweek] "#{BASE_URI}#{END_POINT}/zip/#{@zip_code}#{CPS_WEEK}#{DEFAULT_PARAMS}" else "#{BASE_URI}#{END_POINT}/zip/#{@zip_code}#{DEFAULT_PARAMS}" end end