Class: Onebusaway::ArrivalAndDeparture
Instance Attribute Summary collapse
-
#predictedArrivalTime ⇒ Object
Returns the value of attribute predictedArrivalTime.
-
#predictedDepartureTime ⇒ Object
Returns the value of attribute predictedDepartureTime.
-
#routeId ⇒ Object
Returns the value of attribute routeId.
-
#routeShortName ⇒ Object
Returns the value of attribute routeShortName.
-
#scheduledArrivalTime ⇒ Object
Returns the value of attribute scheduledArrivalTime.
-
#scheduledDepartureTime ⇒ Object
Returns the value of attribute scheduledDepartureTime.
-
#status ⇒ Object
Returns the value of attribute status.
-
#stopId ⇒ Object
Returns the value of attribute stopId.
-
#tripHeadsign ⇒ Object
Returns the value of attribute tripHeadsign.
-
#tripId ⇒ Object
Returns the value of attribute tripId.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Instance Attribute Details
#predictedArrivalTime ⇒ Object
Returns the value of attribute predictedArrivalTime.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def predictedArrivalTime @predictedArrivalTime end |
#predictedDepartureTime ⇒ Object
Returns the value of attribute predictedDepartureTime.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def predictedDepartureTime @predictedDepartureTime end |
#routeId ⇒ Object
Returns the value of attribute routeId.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def routeId @routeId end |
#routeShortName ⇒ Object
Returns the value of attribute routeShortName.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def routeShortName @routeShortName end |
#scheduledArrivalTime ⇒ Object
Returns the value of attribute scheduledArrivalTime.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def scheduledArrivalTime @scheduledArrivalTime end |
#scheduledDepartureTime ⇒ Object
Returns the value of attribute scheduledDepartureTime.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def scheduledDepartureTime @scheduledDepartureTime end |
#status ⇒ Object
Returns the value of attribute status.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def status @status end |
#stopId ⇒ Object
Returns the value of attribute stopId.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def stopId @stopId end |
#tripHeadsign ⇒ Object
Returns the value of attribute tripHeadsign.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def tripHeadsign @tripHeadsign end |
#tripId ⇒ Object
Returns the value of attribute tripId.
124 125 126 |
# File 'lib/onebusaway.rb', line 124 def tripId @tripId end |
Class Method Details
.parse(data) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/onebusaway.rb', line 125 def self.parse(data) arrival = self.new [:routeId, :routeShortName, :tripId, :tripHeadsign, :stopId, :predictedArrivalTime, :scheduledArrivalTime, :predictedDepartureTime, :scheduledDepartureTime, :status].each do |attr| value = data.elements[attr.to_s] arrival.send("#{attr}=", value.text) if value end arrival end |
Instance Method Details
#minutes_from_now ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/onebusaway.rb', line 134 def minutes_from_now @minutes_from_now ||= begin at = predictedArrivalTime.to_i if at == 0 # no predicted time, use scheduled (scheduledArrivalTime.to_i/1000 - Time.now.to_i) / 60 else (predictedArrivalTime.to_i/1000 - Time.now.to_i) / 60 end end @minutes_from_now end |