Class: MBTA::HeavyRail::Platform
- Inherits:
-
Object
- Object
- MBTA::HeavyRail::Platform
- Defined in:
- lib/mbta/heavy_rail/platform.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#station ⇒ Object
readonly
Returns the value of attribute station.
Instance Method Summary collapse
-
#initialize(station, direction, order, key) ⇒ Platform
constructor
A new instance of Platform.
- #predictions ⇒ Object
Constructor Details
#initialize(station, direction, order, key) ⇒ Platform
Returns a new instance of Platform.
6 7 8 9 10 11 |
# File 'lib/mbta/heavy_rail/platform.rb', line 6 def initialize(station, direction, order, key) @station = station @direction = direction @order = order @key = key end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
4 5 6 |
# File 'lib/mbta/heavy_rail/platform.rb', line 4 def direction @direction end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/mbta/heavy_rail/platform.rb', line 4 def key @key end |
#station ⇒ Object (readonly)
Returns the value of attribute station.
4 5 6 |
# File 'lib/mbta/heavy_rail/platform.rb', line 4 def station @station end |
Instance Method Details
#predictions ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/mbta/heavy_rail/platform.rb', line 13 def predictions station.line.trips.inject(Array.new) do |memo, trip| memo << trip[1].announcements.inject(Array.new) do |m, a| m << a if (self.key == a.platform.key && a.type == :prediction) m end end.flatten.compact.sort {|x, y| x.time <=> y.time } end |