Class: CTA::Train::Live
- Inherits:
-
Object
- Object
- CTA::Train::Live
- Defined in:
- lib/cta_redux/models/train.rb
Instance Attribute Summary collapse
-
#heading ⇒ Integer
readonly
The current heading of the train.
-
#lat ⇒ Float
readonly
The current latitude of the train.
-
#lon ⇒ Float
readonly
The current longitude of the train.
-
#predictions ⇒ Array<Prediction>
readonly
An array of Prediction objects that correspond to predictions returned from the TrainTracker API.
Instance Method Summary collapse
-
#initialize(position, predictions) ⇒ Live
constructor
A new instance of Live.
Constructor Details
#initialize(position, predictions) ⇒ Live
Returns a new instance of Live.
77 78 79 80 81 82 |
# File 'lib/cta_redux/models/train.rb', line 77 def initialize(position, predictions) @lat = position["lat"].to_f @lon = position["lon"].to_f @heading = position["heading"].to_i @predictions = Array.wrap(predictions).map { |p| Prediction.new(p) } end |
Instance Attribute Details
#heading ⇒ Integer (readonly)
Returns The current heading of the train.
73 74 75 |
# File 'lib/cta_redux/models/train.rb', line 73 def heading @heading end |
#lat ⇒ Float (readonly)
Returns The current latitude of the train.
69 70 71 |
# File 'lib/cta_redux/models/train.rb', line 69 def lat @lat end |
#lon ⇒ Float (readonly)
Returns The current longitude of the train.
71 72 73 |
# File 'lib/cta_redux/models/train.rb', line 71 def lon @lon end |
#predictions ⇒ Array<Prediction> (readonly)
Returns An array of Prediction objects that correspond to predictions returned from the TrainTracker API.
75 76 77 |
# File 'lib/cta_redux/models/train.rb', line 75 def predictions @predictions end |