Class: Trips::TripResult::Trip
- Inherits:
-
Object
- Object
- Trips::TripResult::Trip
- Defined in:
- lib/oeffi/trips.rb
Instance Attribute Summary collapse
-
#trip ⇒ Object
Returns the value of attribute trip.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(j_trip) ⇒ Trip
constructor
A new instance of Trip.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(j_trip) ⇒ Trip
Returns a new instance of Trip.
23 24 25 |
# File 'lib/oeffi/trips.rb', line 23 def initialize(j_trip) @trip = j_trip end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
40 41 42 |
# File 'lib/oeffi/trips.rb', line 40 def method_missing(method, *args) @trip.send method end |
Instance Attribute Details
#trip ⇒ Object
Returns the value of attribute trip.
22 23 24 |
# File 'lib/oeffi/trips.rb', line 22 def trip @trip end |
Instance Method Details
#as_json ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/oeffi/trips.rb', line 27 def as_json result = { :id => @trip.id, :from => @trip.from.to_s, :to => @trip.to.to_s, :departure => @trip.get_first_public_leg_departure_time.getTime, :arrival => @trip.get_last_public_leg_arrival_time.getTime, :legs => legs.to_a.map { |leg| leg_json leg } } end |