2025-07-03 14:34:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class TrackSerializer
|
2025-07-20 12:57:53 -04:00
|
|
|
def initialize(track)
|
|
|
|
|
@track = track
|
2025-07-03 14:34:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
|
|
|
|
{
|
2025-07-20 12:57:53 -04:00
|
|
|
id: @track.id,
|
|
|
|
|
start_at: @track.start_at.iso8601,
|
|
|
|
|
end_at: @track.end_at.iso8601,
|
|
|
|
|
distance: @track.distance.to_i,
|
|
|
|
|
avg_speed: @track.avg_speed.to_f,
|
|
|
|
|
duration: @track.duration,
|
|
|
|
|
elevation_gain: @track.elevation_gain,
|
|
|
|
|
elevation_loss: @track.elevation_loss,
|
|
|
|
|
elevation_max: @track.elevation_max,
|
|
|
|
|
elevation_min: @track.elevation_min,
|
|
|
|
|
original_path: @track.original_path.to_s
|
2025-07-03 14:34:41 -04:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|