Sha256: 57269b1ef98bf6c527990ceec21c925bf42cf5aadd8c1d9323190c1f0ef0b7dd

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

module MetraSchedule
  class Train
    attr_reader :train_num, :schedule, :bike_limit, :direction, :stops

    def initialize(options={})
      unless options.empty?
        @train_num = options[:train_num] if options.has_key?(:train_num)
        @schedule = options[:schedule] if options.has_key?(:schedule)
        @bike_limit = options[:bike_limit] if options.has_key?(:bike_limit)
        @direction = options[:direction] if options.has_key?(:direction)
        @stops = options[:stops] if options.has_key?(:stops)
      end
    end

    def has_stop?(stop)
      return true if stops.any? {|s| s.station == stop}
      false
    end

    def in_time?(station, time)
      return true if stops.find {|s| s.station == station}.time > time
      false
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metra_schedule-0.2 lib/metra/train.rb
metra_schedule-0.1 lib/metra/train.rb