class Stressfactor::GpxLoader
Attributes
gpx[R]
Public Class Methods
new(gpx_file_path)
click to toggle source
# File lib/stressfactor/gpx_loader.rb, line 5 def initialize(gpx_file_path) @gpx = GPX::GPXFile.new(gpx_file: gpx_file_path) end
Public Instance Methods
intervals()
click to toggle source
An array of instantaneous pace times in min/km from comparing two trackpoints
# File lib/stressfactor/gpx_loader.rb, line 18 def intervals @intervals ||= begin points.map do |p1| idx = points.index(p1) p2 = points[idx+1] if p2 Interval.new(p1, p2) else nil end end end @intervals.compact end
points()
click to toggle source
An array of GPX::TrackPoint objects.
# File lib/stressfactor/gpx_loader.rb, line 35 def points @points ||= gpx.tracks.flat_map(&:points) end
total_time()
click to toggle source
units: seconds
# File lib/stressfactor/gpx_loader.rb, line 10 def total_time intervals.inject(0) do |acc, i| acc + i.time end end