class Vehicle
Public Class Methods
new(json)
click to toggle source
# File lib/vehicle.rb, line 3 def initialize(json) @vehicle_id = json["vehicle_id"] @trip = Trip.new(json["trip"]) @location = Hash[:lat, json["location"]["lat"], :lon, json["location"]["lon"]] @previous_stop_id = json["previous_stop_id"] @next_stop_id = json["next_stop_id"] @origin_stop_id = json["origin_stop_id"] @destination_stop_id = json["destination_stop_id"] @last_updated = DateTime.parse(json["last_updated"]).to_time end
Public Instance Methods
destination_stop_id()
click to toggle source
# File lib/vehicle.rb, line 38 def destination_stop_id @destination_stop_id end
last_updated()
click to toggle source
# File lib/vehicle.rb, line 42 def last_updated @last_updated end
location()
click to toggle source
# File lib/vehicle.rb, line 22 def location @location end
next_stop_id()
click to toggle source
# File lib/vehicle.rb, line 30 def next_stop_id @next_stop_id end
origin_stop_id()
click to toggle source
# File lib/vehicle.rb, line 34 def origin_stop_id @origin_stop_id end
previous_stop_id()
click to toggle source
# File lib/vehicle.rb, line 26 def previous_stop_id @previous_stop_id end
route()
click to toggle source
# File lib/vehicle.rb, line 46 def route @@all_routes.select { |route| route.route_id == self.trip.route_id } end
to_json(*a)
click to toggle source
# File lib/vehicle.rb, line 50 def to_json(*a) { 'vehicle_id' => @vehicle_id, 'lat' => @location[:lat], 'lon' => @location[:lon], 'trip' => @trip, 'route' => self.route, }.to_json(*a) end
trip()
click to toggle source
# File lib/vehicle.rb, line 18 def trip @trip end
vehicle_id()
click to toggle source
# File lib/vehicle.rb, line 14 def vehicle_id @vehicle_id end