lib/ratis/itinerary.rb in ratis-3.6.3 vs lib/ratis/itinerary.rb in ratis-3.6.4

- old
+ new

@@ -1,21 +1,24 @@ module Ratis + class Itinerary < Hashie::Trash + property :legs, transform_with: (lambda do |legs| + Array.wrap(legs[:leg]).map { |l| Hashie::Mash.new l } + end) - class Itinerary - - attr_accessor :co2_auto, :co2_transit, :final_walk_dir, :legs, :reduced_fare, :regular_fare, :transit_time, :trace_info - - def initialize(response) - @co2_auto = response[:co2auto].to_f - @co2_transit = response[:co2transit].to_f - @final_walk_dir = response[:finalwalkdir] - @reduced_fare = response[:reducedfare].to_f - @regular_fare = response[:regularfare].to_f - @transit_time = response[:transittime].to_i - @trace_info = response[:traceinfo] - @legs = response.to_array(:legs, :leg).map { |l| Hashie::Mash.new l } - end - + property :total_walk, from: :totalwalk + property :final_walk, from: :finalwalk + property :final_walk_dir, from: :finalwalkdir + property :final_walk_hint, from: :finalwalkhint + property :transit_time, from: :transittime, with: lambda { |v| v.to_i } + property :regular_fare, from: :regularfare, with: lambda { |v| v.to_f } + property :reduced_fare, from: :reducedfare, with: lambda { |v| v.to_f } + property :fare_info, from: :fareinfo + property :trace_info, from: :traceinfo + property :status_info, from: :statusinfo + property :exmodified + property :exmodids + property :dist_transit, from: :disttransit, with: lambda { |v| v.to_f } + property :dist_auto, from: :distauto, with: lambda { |v| v.to_f } + property :co2_transit, from: :co2transit, with: lambda { |v| v.to_f } + property :co2_auto, from: :co2auto, with: lambda { |v| v.to_f } end - end -