Class: MBTA::HeavyRail::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/mbta/heavy_rail/platform.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#directionObject (readonly)

Returns the value of attribute direction.



4
5
6
# File 'lib/mbta/heavy_rail/platform.rb', line 4

def direction
  @direction
end

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/mbta/heavy_rail/platform.rb', line 4

def key
  @key
end

#stationObject (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

#predictionsObject



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