class Fit4Ruby::DeviceInfo
Public Class Methods
new(field_values = {})
click to toggle source
Calls superclass method
# File lib/fit4ruby/DeviceInfo.rb, line 19 def initialize(field_values = {}) super('device_info') set_field_values(field_values) end
Public Instance Methods
<=>(fdr)
click to toggle source
Ensure that FitDataRecords have a deterministic sequence. Device infos are sorted by device_index.
# File lib/fit4ruby/DeviceInfo.rb, line 26 def <=>(fdr) @timestamp == fdr.timestamp ? @message.name == fdr.message.name ? @device_index <=> fdr.device_index : RecordOrder.index(@message.name) <=> RecordOrder.index(fdr.message.name) : @timestamp <=> fdr.timestamp end
check(index)
click to toggle source
# File lib/fit4ruby/DeviceInfo.rb, line 72 def check(index) unless @device_index Log.fatal 'device info record must have a device_index' end if @device_index == 0 unless @manufacturer Log.fatal 'device info record 0 must have a manufacturer field set' end if @manufacturer == 'garmin' unless @garmin_product Log.fatal 'device info record 0 must have a garman_product ' + 'field set' end else unless @product Log.fatal 'device info record 0 must have a product field set' end end if @serial_number.nil? Log.fatal 'device info record 0 must have a serial number set' end end end
numeric_manufacturer()
click to toggle source
# File lib/fit4ruby/DeviceInfo.rb, line 35 def numeric_manufacturer if @manufacturer && @manufacturer.is_a?(String) if @manufacturer[0..17] == 'Undocumented value' return @manufacturer[18..-1].to_i else return GlobalFitDictionaries['manufacturer']. value_by_name(@manufacturer) end end Log.fatal "Unexpected @manufacturer (#{@manufacturer}) value" end
numeric_product()
click to toggle source
# File lib/fit4ruby/DeviceInfo.rb, line 48 def numeric_product # The numeric product ID must be an integer or nil. In case the # dictionary did not contain an entry for the numeric ID in the fit file # the @garmin_product or @product variables contain a String starting # with 'Undocumented value ' followed by the ID. if @garmin_product && @garmin_product.is_a?(String) if @garmin_product[0..17] == 'Undocumented value' return @garmin_product[18..-1].to_i else return GlobalFitDictionaries['garmin_product']. value_by_name(@garmin_product) end elsif @product && @product.is_a?(String) if @product[0..17] == 'Undocumented value' return @product[18..-1].to_i else return GlobalFitDictionaries['product'].value_by_name(@product) end end Log.fatal "Unexpected @product (#{@product}) or " + "@garmin_product (#{@garmin_product}) values" end