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.
149 150 151 152 153 154 |
# File 'lib/cta_redux/models/train.rb', line 149 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.
145 146 147 |
# File 'lib/cta_redux/models/train.rb', line 145 def heading @heading end |
#lat ⇒ Float (readonly)
Returns The current latitude of the train.
141 142 143 |
# File 'lib/cta_redux/models/train.rb', line 141 def lat @lat end |
#lon ⇒ Float (readonly)
Returns The current longitude of the train.
143 144 145 |
# File 'lib/cta_redux/models/train.rb', line 143 def lon @lon end |
#predictions ⇒ Array<Prediction> (readonly)
Returns An array of Prediction objects that correspond to predictions returned from the TrainTracker API.
147 148 149 |
# File 'lib/cta_redux/models/train.rb', line 147 def predictions @predictions end |