Class: Fit4Ruby::Length
- Inherits:
-
FitDataRecord
- Object
- FitDataRecord
- Fit4Ruby::Length
- Includes:
- RecordAggregator
- Defined in:
- lib/fit4ruby/Length.rb
Constant Summary
Constants inherited from FitDataRecord
Constants included from BDFieldNameTranslator
BDFieldNameTranslator::BD_DICT
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Attributes inherited from FitDataRecord
Instance Method Summary collapse
- #check(index) ⇒ Object
-
#initialize(records, previous_length, field_values) ⇒ Length
constructor
A new instance of Length.
Methods included from RecordAggregator
#aggregate, #aggregate_ascent_descent, #aggregate_geo_region, #aggregate_heart_rate, #aggregate_speed_distance, #aggregate_stance_time, #aggregate_strides, #aggregate_vertical_oscillation
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, #fit_time_to_time, #secsToDHMS, #secsToHM, #secsToHMS, #speedToPace, #time_to_fit_time
Constructor Details
#initialize(records, previous_length, field_values) ⇒ Length
Returns a new instance of Length.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fit4ruby/Length.rb', line 24 def initialize(records, previous_length, field_values) super('length') @records = records @previous_length = previous_length if previous_length && previous_length.records && previous_length.records.last # Set the start time of the new length to the timestamp of the last record # of the previous length. @start_time = previous_length.records.last. elsif records.first # Or to the timestamp of the first record. @start_time = records.first. end if records.last @total_elapsed_time = records.last. - @start_time end set_field_values(field_values) end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
22 23 24 |
# File 'lib/fit4ruby/Length.rb', line 22 def records @records end |
Instance Method Details
#check(index) ⇒ Object
45 46 47 48 49 |
# File 'lib/fit4ruby/Length.rb', line 45 def check(index) unless @message_index == index Log.fatal "message_index must be #{index}, not #{@message_index}" end end |