class Fit::File::Definition::Field
Public Instance Methods
data()
click to toggle source
# File lib/fit/file/definition.rb, line 14 def data @data ||= Definitions.get_field(parent.parent.global_message_number.snapshot, field_definition_number.snapshot) || { :name => "field_#{field_definition_number.snapshot}", :scale => nil } end
dyn_data()
click to toggle source
# File lib/fit/file/definition.rb, line 20 def dyn_data @dyn_data ||= Definitions.get_dynamic_fields(parent.parent.global_message_number.snapshot, field_definition_number.snapshot) end
length()
click to toggle source
return the length in byte of the given type
# File lib/fit/file/definition.rb, line 93 def length @length end
name()
click to toggle source
# File lib/fit/file/definition.rb, line 25 def name data[:name] end
raw_name()
click to toggle source
# File lib/fit/file/definition.rb, line 29 def raw_name "raw_#{name}" end
real_type()
click to toggle source
# File lib/fit/file/definition.rb, line 37 def real_type data[:type] end
scale()
click to toggle source
# File lib/fit/file/definition.rb, line 33 def scale data[:scale] end
size()
click to toggle source
field_size is in byte
# File lib/fit/file/definition.rb, line 88 def size field_size end
type()
click to toggle source
# File lib/fit/file/definition.rb, line 41 def type case base_type_number.snapshot when 0 # enum build_int_type 8, false when 1 build_int_type 8, true when 2 build_int_type 8, false when 3 build_int_type 16, true when 4 build_int_type 16, false when 5 build_int_type 32, true when 6 build_int_type 32, false when 7 # some cases found where string has the max field length # and is therefore not null terminated @length = 1 "string" when 8 @length = 4 "float" when 9 @length = 8 "double" when 10 # uint8z build_int_type 8, false when 11 # uint16z build_int_type 16, false when 12 # uint32z build_int_type 32, false when 13 # array of bytes build_int_type 8, false when 14 # sint64 build_int_type 64, true when 15 # uint64 build_int_type 64, false when 16 # uint64z build_int_type 64, false else raise "Can't map base_type_number #{base_type_number} to a data type" end end
Private Instance Methods
build_int_type(length, signed)
click to toggle source
# File lib/fit/file/definition.rb, line 99 def build_int_type(length, signed) # @length is in byte not in bits, so divide by 8 @length = length/8 (signed ? '' : 'u') << 'int' << length.to_s end