aboutsummaryrefslogtreecommitdiffstats
path: root/lib/way_cost_collection_json_serializer.rb
blob: 191871ccacba44650292bdee0614bd419193cb9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class WayCostCollectionJSONSerializer
  def self.dump(way_costs)
    return if way_costs.nil?

    costs_by_id = {}

    way_costs.each do |way_cost|
      costs_by_id[way_cost.id] = {
        distance: way_cost.distance,
        time: way_cost.time
      }
    end

    JSON.dump(costs_by_id)
  end
end