Class: MetraSchedule::Stop

Inherits:
Object
  • Object
show all
Defined in:
lib/metra/stop.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Stop

Returns a new instance of Stop.



5
6
7
8
9
10
11
# File 'lib/metra/stop.rb', line 5

def initialize(options={})
  unless options.has_key?(:station) and options.has_key?(:time)
    raise ArgumentError.new "Stop objects must have a station and a time"
  end
  @station = options[:station] if options.has_key?(:station)
  @time = options[:time] if options.has_key?(:time)
end

Instance Attribute Details

#stationObject (readonly)

Returns the value of attribute station.



3
4
5
# File 'lib/metra/stop.rb', line 3

def station
  @station
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/metra/stop.rb', line 3

def time
  @time
end

Class Method Details

.pretty_print(sym) ⇒ Object



17
18
19
# File 'lib/metra/stop.rb', line 17

def self.pretty_print(sym)
  sym.to_s.split("_").map {|s| s.capitalize}.join("\s")
end

Instance Method Details

#is_after?(time) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/metra/stop.rb', line 13

def is_after?(time)
  @time > time
end