Class: Bort::Schedule::Fare

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Fare.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bort/schedule.rb', line 110

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

  download_options = {
    :action => 'sched',
    :cmd    => 'fare',
    :orig   => origin,
    :dest   => destination,
    :date   => date,
    :sched  => schedule_number,
  }

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

  self.schedule_number  = (data/:sched_num).inner_text.to_i
  self.fare             = (data/:fare).inner_text.to_f
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



108
109
110
# File 'lib/bort/schedule.rb', line 108

def date
  @date
end

#destinationObject

Returns the value of attribute destination.



108
109
110
# File 'lib/bort/schedule.rb', line 108

def destination
  @destination
end

#fareObject

Returns the value of attribute fare.



108
109
110
# File 'lib/bort/schedule.rb', line 108

def fare
  @fare
end

#originObject

Returns the value of attribute origin.



108
109
110
# File 'lib/bort/schedule.rb', line 108

def origin
  @origin
end

#schedule_numberObject

Returns the value of attribute schedule_number.



108
109
110
# File 'lib/bort/schedule.rb', line 108

def schedule_number
  @schedule_number
end