Class: CTA::TrainTracker::FollowResponse
- Inherits:
-
API::Response
- Object
- API::Response
- CTA::TrainTracker::FollowResponse
- Defined in:
- lib/cta_redux/api/train_tracker.rb
Instance Attribute Summary collapse
-
#predictions ⇒ Array<CTA::Train::Prediction>
readonly
An array of CTA::Train::Prediction objects that correspond to the predictions requested.
-
#train ⇒ CTA::Train
readonly
The CTA::Train that corresponds to the train for which you’ve requested follow predictions.
Attributes inherited from API::Response
#error, #parsed_body, #raw_body, #timestamp
Instance Method Summary collapse
-
#initialize(parsed_body, raw_body, debug) ⇒ FollowResponse
constructor
A new instance of FollowResponse.
Constructor Details
#initialize(parsed_body, raw_body, debug) ⇒ FollowResponse
Returns a new instance of FollowResponse.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cta_redux/api/train_tracker.rb', line 53 def initialize(parsed_body, raw_body, debug) super(parsed_body, raw_body, debug) train_info = Array.wrap(parsed_body["ctatt"]["eta"]).first @train = CTA::Train.find_active_run(train_info["rn"], self., (train_info["isDly"] == "1")).first if !@train @train = CTA::Train.find_active_run(train_info["rn"], self., true).first end @train.live = CTA::Train::Live.new(parsed_body["ctatt"]["position"], parsed_body["ctatt"]["eta"]) @predictions = @train.live.predictions end |
Instance Attribute Details
#predictions ⇒ Array<CTA::Train::Prediction> (readonly)
Note:
Convenience method, equivalent to calling train.map { |t| t.live.predictions }.flatten
Returns An array of CTA::Train::Prediction objects that correspond to the predictions requested.
51 52 53 |
# File 'lib/cta_redux/api/train_tracker.rb', line 51 def predictions @predictions end |
#train ⇒ CTA::Train (readonly)
Returns The CTA::Train that corresponds to the train for which you’ve requested follow predictions.
48 49 50 |
# File 'lib/cta_redux/api/train_tracker.rb', line 48 def train @train end |