Class: CTA::Train::Live

Inherits:
Object
  • Object
show all
Defined in:
lib/cta_redux/models/train.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#headingInteger (readonly)

Returns The current heading of the train.

Returns:

  • (Integer)

    The current heading of the train



145
146
147
# File 'lib/cta_redux/models/train.rb', line 145

def heading
  @heading
end

#latFloat (readonly)

Returns The current latitude of the train.

Returns:

  • (Float)

    The current latitude of the train



141
142
143
# File 'lib/cta_redux/models/train.rb', line 141

def lat
  @lat
end

#lonFloat (readonly)

Returns The current longitude of the train.

Returns:

  • (Float)

    The current longitude of the train



143
144
145
# File 'lib/cta_redux/models/train.rb', line 143

def lon
  @lon
end

#predictionsArray<Prediction> (readonly)

Returns An array of Prediction objects that correspond to predictions returned from the TrainTracker API.

Returns:



147
148
149
# File 'lib/cta_redux/models/train.rb', line 147

def predictions
  @predictions
end