dawarich/app/serializers/points/gpx_serializer.rb

27 lines
424 B
Ruby
Raw Normal View History

2024-09-02 15:35:08 -04:00
# frozen_string_literal: true
class Points::GpxSerializer
def initialize(points)
@points = points
end
def call
gpx = GPX::GPXFile.new
2024-09-02 15:35:08 -04:00
points.each do |point|
gpx.waypoints << GPX::Waypoint.new(
lat: point.latitude.to_f,
lon: point.longitude.to_f,
2024-09-28 06:45:22 -04:00
time: point.recorded_at,
ele: point.altitude.to_f
)
end
gpx
2024-09-02 15:35:08 -04:00
end
private
attr_reader :points
end