Sha256: 7ed906a39946c915ff9a71b1c066e0687d8f297d1e9d5581b4b54442a793a397

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

module MBTA
  module HeavyRail
    class Platform
      attr_reader :station, :direction, :key

      def initialize(station, direction, order, key)
        @station = station
        @direction = direction
        @order = order
        @key = key
      end

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mbta-0.1.4 lib/mbta/heavy_rail/platform.rb
mbta-0.1.3 lib/mbta/heavy_rail/platform.rb
mbta-0.1.1 lib/mbta/heavy_rail/platform.rb