Sha256: 8b993dab54bc0439ddf6a85e8e2c8147f2183a71f039f049451bbf932214f438
Contents?: true
Size: 1.44 KB
Versions: 5
Compression:
Stored size: 1.44 KB
Contents
#!/usr/bin/env ruby -w # encoding: UTF-8 # # = Record.rb -- Fit4Ruby - FIT file processing library for Ruby # # Copyright (c) 2014 by Chris Schlaeger <cs@taskjuggler.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # require 'fit4ruby/FitDataRecord' module Fit4Ruby # The Record corresponds to the record FIT message. A Record is a basic set # of primary measurements that are associated with a certain timestamp. class Record < FitDataRecord # Create a new Record object. # @param field_values [Hash] Hash that provides initial values for certain # fields. def initialize(field_values = {}) super('record') @meta_field_units['pace'] = 'min/km' @meta_field_units['run_cadence'] = 'spm' set_field_values(field_values) end def run_cadence if @cadence && @fractional_cadence (@cadence + @fractional_cadence) * 2 elsif @cadence @cadence * 2 else nil end end # Convert the 'speed' or 'enhanced_speed' field into a running pace. The # pace is measured in minutes per Kilometer. # @return [Float or nil] pace for this Record in m/s or nil if not # available. def pace return nil unless @speed || @enhanced_speed 1000.0 / ((@speed || @enhanced_speed) * 60.0) end end end
Version data entries
5 entries across 5 versions & 1 rubygems