Class: Bort::Route::Info

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, options = {}) ⇒ Info

Returns a new instance of Info.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/bort/route.rb', line 69

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

  download_options = {
    :action => 'route',
    :cmd => 'routeinfo',
    :route => route_number,
  }
  download_options[:sched]  = schedule_number
  download_options[:date]   = date

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

  self.schedule_number  = (data/:sched_num).inner_text
  self.name             = (data/:route/:name).inner_text
  self.abbreviation     = (data/:route/:abbr).inner_text
  self.route_number     = (data/:route/:number).inner_text
  self.origin           = (data/:route/:origin).inner_text
  self.destination      = (data/:route/:destination).inner_text
  self.color            = (data/:route/:color).inner_text
  self.holidays         = (data/:route/:holidays).inner_text
  self.stations         = (data/:route/:config/:station).map(&:inner_text)
end

Instance Attribute Details

#abbreviationObject

Returns the value of attribute abbreviation.



66
67
68
# File 'lib/bort/route.rb', line 66

def abbreviation
  @abbreviation
end

#colorObject

Returns the value of attribute color.



66
67
68
# File 'lib/bort/route.rb', line 66

def color
  @color
end

#dateObject

Returns the value of attribute date.



66
67
68
# File 'lib/bort/route.rb', line 66

def date
  @date
end

#destinationObject

Returns the value of attribute destination.



66
67
68
# File 'lib/bort/route.rb', line 66

def destination
  @destination
end

#holidaysObject

Returns the value of attribute holidays.



66
67
68
# File 'lib/bort/route.rb', line 66

def holidays
  @holidays
end

#nameObject

Returns the value of attribute name.



66
67
68
# File 'lib/bort/route.rb', line 66

def name
  @name
end

#originObject

Returns the value of attribute origin.



66
67
68
# File 'lib/bort/route.rb', line 66

def origin
  @origin
end

#route_idObject

Returns the value of attribute route_id.



66
67
68
# File 'lib/bort/route.rb', line 66

def route_id
  @route_id
end

#route_numberObject

Returns the value of attribute route_number.



66
67
68
# File 'lib/bort/route.rb', line 66

def route_number
  @route_number
end

#schedule_numberObject

Returns the value of attribute schedule_number.



66
67
68
# File 'lib/bort/route.rb', line 66

def schedule_number
  @schedule_number
end

#stationsObject

Returns the value of attribute stations.



66
67
68
# File 'lib/bort/route.rb', line 66

def stations
  @stations
end