Class: Fit4Ruby::Record
- Inherits:
-
FitDataRecord
- Object
- FitDataRecord
- Fit4Ruby::Record
- Includes:
- FDR_DevField_Extension
- Defined in:
- lib/fit4ruby/Record.rb
Overview
The Record corresponds to the record FIT message. A Record is a basic set of primary measurements that are associated with a certain timestamp.
Constant Summary
Constants inherited from FitDataRecord
Constants included from BDFieldNameTranslator
BDFieldNameTranslator::BD_DICT
Constants included from Converters
Converters::FACTORS, Converters::OFFSETS
Instance Attribute Summary
Attributes inherited from FitDataRecord
Instance Method Summary collapse
-
#initialize(top_level_record, field_values = {}) ⇒ Record
constructor
Create a new Record object.
-
#pace ⇒ Float or nil
Convert the ‘speed’ or ‘enhanced_speed’ field into a running pace.
- #run_cadence ⇒ Object
Methods included from FDR_DevField_Extension
#create_dev_field_instance_variables, #each_developer_field, #export, #get_unit_by_name
Methods inherited from FitDataRecord
#<=>, #==, #export, #get, #get_as, #get_unit_by_name, #set, #set_field_values, #write
Methods included from BDFieldNameTranslator
Methods included from Converters
#conversion_factor, #conversion_offset, #fit_time_to_time, #secsToDHMS, #secsToHM, #secsToHMS, #speedToPace, #time_to_fit_time
Constructor Details
#initialize(top_level_record, field_values = {}) ⇒ Record
Create a new Record object.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fit4ruby/Record.rb', line 28 def initialize(top_level_record, field_values = {}) super('record') @top_level_record = top_level_record @meta_field_units['pace'] = 'min/km' @meta_field_units['run_cadence'] = 'spm' # Create instance variables for developer fields create_dev_field_instance_variables set_field_values(field_values) end |
Instance Method Details
#pace ⇒ Float or nil
Convert the ‘speed’ or ‘enhanced_speed’ field into a running pace. The pace is measured in minutes per Kilometer.
54 55 56 57 58 |
# File 'lib/fit4ruby/Record.rb', line 54 def pace return nil unless @speed || @enhanced_speed 1000.0 / ((@speed || @enhanced_speed) * 60.0) end |
#run_cadence ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/fit4ruby/Record.rb', line 40 def run_cadence if @cadence && @fractional_cadence (@cadence + @fractional_cadence) * 2 elsif @cadence @cadence * 2 else nil end end |