Class: Bort::Schedule::Trip

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def destination
  @destination
end

#destination_dateObject

Returns the value of attribute destination_date.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def destination_date
  @destination_date
end

#destination_timeObject

Returns the value of attribute destination_time.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def destination_time
  @destination_time
end

#fareObject

Returns the value of attribute fare.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def fare
  @fare
end

#legsObject

Returns the value of attribute legs.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def legs
  @legs
end

#originObject

Returns the value of attribute origin.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def origin
  @origin
end

#origin_dateObject

Returns the value of attribute origin_date.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def origin_date
  @origin_date
end

#origin_timeObject

Returns the value of attribute origin_time.



62
63
64
# File 'lib/bort/schedule.rb', line 62

def origin_time
  @origin_time
end

Class Method Details

.parse(doc) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/bort/schedule.rb', line 65

def self.parse(doc)
  trip                  = Trip.new
  trip.origin           = doc.attributes['origin']
  trip.destination      = doc.attributes['destination']
  trip.fare             = doc.attributes['fare'].to_f
  trip.origin_date      = Date.parse(doc.attributes['origtimedate'])
  trip.destination_date = Date.parse(doc.attributes['desttimedate'])
  trip.origin_time      = Time.parse("#{doc.attributes['origtimedate']} #{doc.attributes['origtimemin']}")
  trip.destination_time = Time.parse("#{doc.attributes['desttimedate']} #{doc.attributes['desttimemin']}")
  trip.legs             = (doc/:leg).map{|leg| Leg.parse(leg)}

  trip
end