Class: Bort::Schedule::Trip
- Inherits:
-
Object
- Object
- Bort::Schedule::Trip
- Defined in:
- lib/bort/schedule.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#destination_date ⇒ Object
Returns the value of attribute destination_date.
-
#destination_time ⇒ Object
Returns the value of attribute destination_time.
-
#fare ⇒ Object
Returns the value of attribute fare.
-
#legs ⇒ Object
Returns the value of attribute legs.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#origin_date ⇒ Object
Returns the value of attribute origin_date.
-
#origin_time ⇒ Object
Returns the value of attribute origin_time.
Class Method Summary collapse
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def destination @destination end |
#destination_date ⇒ Object
Returns the value of attribute destination_date.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def destination_date @destination_date end |
#destination_time ⇒ Object
Returns the value of attribute destination_time.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def destination_time @destination_time end |
#fare ⇒ Object
Returns the value of attribute fare.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def fare @fare end |
#legs ⇒ Object
Returns the value of attribute legs.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def legs @legs end |
#origin ⇒ Object
Returns the value of attribute origin.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def origin @origin end |
#origin_date ⇒ Object
Returns the value of attribute origin_date.
62 63 64 |
# File 'lib/bort/schedule.rb', line 62 def origin_date @origin_date end |
#origin_time ⇒ Object
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 |