class Fit4Ruby::Length

Attributes

records[R]

Public Class Methods

new(records, previous_length, field_values) click to toggle source
Calls superclass method Fit4Ruby::FitDataRecord::new
# 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.timestamp
  elsif records.first
    # Or to the timestamp of the first record.
    @start_time = records.first.timestamp
  end

  if records.last
    @total_elapsed_time = records.last.timestamp - @start_time
  end

  set_field_values(field_values)
end

Public Instance Methods

check(index) click to toggle source
# 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