Class: Bort::Schedule::StationSchedule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin, options = {}) ⇒ StationSchedule

Returns a new instance of StationSchedule.



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/bort/schedule.rb', line 293

def initialize(origin, options={})
  load_options(options)

  download_options = {
    :action => 'sched',
    :cmd    => 'stnsched',
    :orig   => origin,
    :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.name             = (data/:name).inner_text
  self.abbreviation     = (data/:abbr).inner_text
  self.legend           = (data/:legend).inner_text
  self.schedules        = (data/:station/:item).map{|line| StationLine.parse(line, date)}
end

Instance Attribute Details

#abbreviationObject

Returns the value of attribute abbreviation.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def abbreviation
  @abbreviation
end

#dateObject

Returns the value of attribute date.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def date
  @date
end

#legendObject

Returns the value of attribute legend.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def legend
  @legend
end

#nameObject

Returns the value of attribute name.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def name
  @name
end

#originObject

Returns the value of attribute origin.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def origin
  @origin
end

#schedule_numberObject

Returns the value of attribute schedule_number.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def schedule_number
  @schedule_number
end

#schedulesObject

Returns the value of attribute schedules.



291
292
293
# File 'lib/bort/schedule.rb', line 291

def schedules
  @schedules
end