Class: BusTime::Prediction
- Inherits:
-
Object
- Object
- BusTime::Prediction
- Defined in:
- lib/bus_time/prediction.rb
Overview
Service bus stop prediction handling, including prediction retrieval via BusTime::Api
Instance Attribute Summary collapse
-
#arrival_minutes ⇒ Object
readonly
Returns the value of attribute arrival_minutes.
-
#arrives_at ⇒ Object
readonly
Returns the value of attribute arrives_at.
-
#delayed ⇒ Object
readonly
Returns the value of attribute delayed.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#prediction_type ⇒ Object
readonly
Returns the value of attribute prediction_type.
-
#route_id ⇒ Object
readonly
Returns the value of attribute route_id.
-
#stop_id ⇒ Object
readonly
Returns the value of attribute stop_id.
-
#stop_name ⇒ Object
readonly
Returns the value of attribute stop_name.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#trip_id ⇒ Object
readonly
Returns the value of attribute trip_id.
-
#vehicle_id ⇒ Object
readonly
Returns the value of attribute vehicle_id.
Instance Method Summary collapse
- #delayed? ⇒ Boolean
-
#initialize(route_id, direction, stop_id, arrival_minutes, **opts) ⇒ Prediction
constructor
A new instance of Prediction.
Constructor Details
#initialize(route_id, direction, stop_id, arrival_minutes, **opts) ⇒ Prediction
Returns a new instance of Prediction.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bus_time/prediction.rb', line 11 def initialize(route_id, direction, stop_id, arrival_minutes, **opts) @route_id = route_id @stop_id = stop_id @direction = direction @arrival_minutes = arrival_minutes @trip_id = opts[:trip_id] @vehicle_id = opts[:vehicle_id] @destination = opts[:destination] @stop_name = opts[:stop_name] @arrives_at = opts[:arrives_at] @prediction_type = opts[:prediction_type] || "arrival" @delayed = opts[:delayed] || false @generated_at = opts[:generated_at] || DateTime.now end |
Instance Attribute Details
#arrival_minutes ⇒ Object (readonly)
Returns the value of attribute arrival_minutes.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def arrival_minutes @arrival_minutes end |
#arrives_at ⇒ Object (readonly)
Returns the value of attribute arrives_at.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def arrives_at @arrives_at end |
#delayed ⇒ Object (readonly)
Returns the value of attribute delayed.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def delayed @delayed end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def destination @destination end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def direction @direction end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def generated_at @generated_at end |
#prediction_type ⇒ Object (readonly)
Returns the value of attribute prediction_type.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def prediction_type @prediction_type end |
#route_id ⇒ Object (readonly)
Returns the value of attribute route_id.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def route_id @route_id end |
#stop_id ⇒ Object (readonly)
Returns the value of attribute stop_id.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def stop_id @stop_id end |
#stop_name ⇒ Object (readonly)
Returns the value of attribute stop_name.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def stop_name @stop_name end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def time @time end |
#trip_id ⇒ Object (readonly)
Returns the value of attribute trip_id.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def trip_id @trip_id end |
#vehicle_id ⇒ Object (readonly)
Returns the value of attribute vehicle_id.
6 7 8 |
# File 'lib/bus_time/prediction.rb', line 6 def vehicle_id @vehicle_id end |
Instance Method Details
#delayed? ⇒ Boolean
30 31 32 |
# File 'lib/bus_time/prediction.rb', line 30 def delayed? @delayed end |