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.



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

#headingInteger (readonly)

Returns The current heading of the train.

Returns:

  • (Integer)

    The current heading of the train



73
74
75
# File 'lib/cta_redux/models/train.rb', line 73

def heading
  @heading
end

#latFloat (readonly)

Returns The current latitude of the train.

Returns:

  • (Float)

    The current latitude of the train



69
70
71
# File 'lib/cta_redux/models/train.rb', line 69

def lat
  @lat
end

#lonFloat (readonly)

Returns The current longitude of the train.

Returns:

  • (Float)

    The current longitude of the train



71
72
73
# File 'lib/cta_redux/models/train.rb', line 71

def lon
  @lon
end

#predictionsArray<Prediction> (readonly)

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

Returns:



75
76
77
# File 'lib/cta_redux/models/train.rb', line 75

def predictions
  @predictions
end