Module: Aucklandia::VehiclePositions
- Included in:
- Client
- Defined in:
- lib/aucklandia/vehicle_positions.rb
Constant Summary collapse
- VEHICLE_POSITIONS_ENDPOINT =
'/public/realtime/vehiclelocations'
Instance Method Summary collapse
- #get_vehicle_position_by_vehicle_id(vehicle_id) ⇒ Object
- #get_vehicle_positions(trip_id: nil, vehicle_id: nil) ⇒ Object
- #get_vehicle_positions_by_route_id(route_id) ⇒ Object
Instance Method Details
#get_vehicle_position_by_vehicle_id(vehicle_id) ⇒ Object
16 17 18 |
# File 'lib/aucklandia/vehicle_positions.rb', line 16 def get_vehicle_position_by_vehicle_id(vehicle_id) get_vehicle_positions(vehicle_id: vehicle_id).first end |
#get_vehicle_positions(trip_id: nil, vehicle_id: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/aucklandia/vehicle_positions.rb', line 5 def get_vehicle_positions(trip_id: nil, vehicle_id: nil) params = { tripid: trip_id, vehicleid: vehicle_id }.delete_if { |k,v| v.nil? } url = build_url(BASE_URL, VEHICLE_POSITIONS_ENDPOINT, params: params) response = get(url) JSON.parse(response)['response']['entity'] end |
#get_vehicle_positions_by_route_id(route_id) ⇒ Object
20 21 22 23 24 |
# File 'lib/aucklandia/vehicle_positions.rb', line 20 def get_vehicle_positions_by_route_id(route_id) get_vehicle_positions.select do |vehicle_position| vehicle_position if vehicle_position['vehicle']['trip']['route_id'] == route_id end end |