Class: Bort::Schedule::RouteSchedule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route_num, options = {}) ⇒ RouteSchedule

Returns a new instance of RouteSchedule.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/bort/schedule.rb', line 168

def initialize(route_num, options={})
  self.route_number = route_num
  load_options(options)

  download_options = {
    :action => 'sched',
    :cmd    => 'routesched',
    :route  => route_number,
    :sched  => schedule_number,
    :date   => date,
    :l      => legend,
  }

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

  self.date             = Date.parse((data/:date).inner_text)
  self.schedule_number  = (data/:sched_num).inner_text.to_i
  self.trains           = (data/:train).map{|train| TrainSchedule.parse(train, date)}
  self.legend           = (data/:legend).inner_text
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



166
167
168
# File 'lib/bort/schedule.rb', line 166

def date
  @date
end

#legendObject

Returns the value of attribute legend.



166
167
168
# File 'lib/bort/schedule.rb', line 166

def legend
  @legend
end

#route_numberObject

Returns the value of attribute route_number.



166
167
168
# File 'lib/bort/schedule.rb', line 166

def route_number
  @route_number
end

#schedule_numberObject

Returns the value of attribute schedule_number.



166
167
168
# File 'lib/bort/schedule.rb', line 166

def schedule_number
  @schedule_number
end

#trainsObject

Returns the value of attribute trains.



166
167
168
# File 'lib/bort/schedule.rb', line 166

def trains
  @trains
end