Class: Trips::TripResult::Trip

Inherits:
Object
  • Object
show all
Defined in:
lib/oeffi/trips.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tripObject

Returns the value of attribute trip.



22
23
24
# File 'lib/oeffi/trips.rb', line 22

def trip
  @trip
end

Instance Method Details

#as_jsonObject



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