Class: Fit4Ruby::FitDefinition

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/fit4ruby/FitDefinition.rb

Overview

The FitDefinition contains the blueprints for FitMessageRecord segments of FIT files. Before a message record can occur in a FIT file, its definition must be included in the FIT file. The definition holds enough information about the message record to define its size. It also contains some basic information how to interpret the data in the record. To fully understand the message record data the full definition in the GlobalFitMessage is required.

Instance Method Summary collapse

Instance Method Details

#checkObject



42
43
44
45
46
47
# File 'lib/fit4ruby/FitDefinition.rb', line 42

def check
  if architecture.snapshot > 1
    Log.fatal "Illegal architecture value #{architecture.snapshot}"
  end
  fields.each { |f| f.check }
end

#endianObject



38
39
40
# File 'lib/fit4ruby/FitDefinition.rb', line 38

def endian
  architecture.snapshot == 0 ? :little : :big
end

#setup(fit_message_definition) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/fit4ruby/FitDefinition.rb', line 49

def setup(fit_message_definition)
  fit_message_definition.fields_by_number.each do |number, f|
    fdf = FitDefinitionField.new
    fdf.field_definition_number = number
    fdf.set_type(f.type)

    fields << fdf
  end
  self.field_count = fields.length
end