Class: Bort::Schedule::Trips

Inherits:
Object
  • Object
show all
Defined in:
lib/bort/schedule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, orig, dest, options = {}) ⇒ Trips

Returns a new instance of Trips.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bort/schedule.rb', line 15

def initialize(command, orig, dest, options={})
  self.origin = orig
  self.destination = dest
  load_options(options)

  download_options = {
    :action => 'sched',
    :cmd    => command,
    :orig   => origin,
    :dest   => destination,
    :time   => time,
    :date   => date,
    :b      => before,
    :a      => after,
    :l      => legend,
  }

  xml = Util.download(download_options)
  data = Hpricot(xml)

  self.date             = Date.parse((data/:date).inner_text)
  self.time             = Time.parse("#{(data/:date).inner_text} #{(data/:time).inner_text}")
  self.before           = (data/:before).inner_text.to_i
  self.after            = (data/:after).inner_text.to_i
  self.legend           = (data/:legend).inner_text
  self.schedule_number  = (data/:sched_num).inner_text
  self.trips            = (data/:trip).map{|trip| Trip.parse(trip)}
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def after
  @after
end

#beforeObject

Returns the value of attribute before.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def before
  @before
end

#dateObject

Returns the value of attribute date.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def date
  @date
end

#destinationObject

Returns the value of attribute destination.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def destination
  @destination
end

#legendObject

Returns the value of attribute legend.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def legend
  @legend
end

#originObject

Returns the value of attribute origin.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def origin
  @origin
end

#schedule_numberObject

Returns the value of attribute schedule_number.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def schedule_number
  @schedule_number
end

#timeObject

Returns the value of attribute time.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def time
  @time
end

#tripsObject

Returns the value of attribute trips.



12
13
14
# File 'lib/bort/schedule.rb', line 12

def trips
  @trips
end