Sha256: 36ad33762e9178f2da5d8b5a92e2d2378e533e673c0f18760eb591d10ef00d1c

Contents?: true

Size: 1.1 KB

Versions: 18

Compression:

Stored size: 1.1 KB

Contents

#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = SensorSettings.rb -- Fit4Ruby - FIT file processing library for Ruby
#
# Copyright (c) 2017 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

  class SensorSettings < FitDataRecord

    def initialize(field_values = {})
      super('sensor_settings')
      set_field_values(field_values)
    end

    # Ensure that FitDataRecords have a deterministic sequence. Sensor
    # settings are sorted by message_index.
    def <=>(fdr)
      @timestamp == fdr.timestamp ?
        @message.name == fdr.message.name ?
          @message_index <=> fdr.message_index :
          RecordOrder.index(@message.name) <=>
            RecordOrder.index(fdr.message.name) :
        @timestamp <=> fdr.timestamp
    end

    def check(index)
      unless @message_index
        Log.fatal 'sensor setting record must have a message_index'
      end
    end

  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fit4ruby-3.13.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.12.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.11.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.10.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.9.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.8.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.7.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.6.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.5.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.4.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.3.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.2.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.1.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-3.0.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-2.0.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-1.7.0 lib/fit4ruby/SensorSettings.rb
fit4ruby-1.6.2 lib/fit4ruby/SensorSettings.rb
fit4ruby-1.6.1 lib/fit4ruby/SensorSettings.rb