class RecordHeader

Attributes

header_type[RW]
local_message_type[RW]
message_type[RW]
message_type_specific[RW]
time_offset[RW]

Public Class Methods

new(io) click to toggle source
# File lib/fitreader/record_header.rb, line 4
def initialize(io)
  byte = io.readbyte

  @header_type = read_bit(byte, 7)             # 0 = normal, 1 = timestamp
  if @header_type.zero?
    @message_type = read_bit(byte, 6)          # 1 = definition, 0 = data
    @message_type_specific = read_bit(byte, 5) # 1 = developer fields
    @reserved = read_bit(byte, 4)
    @local_message_type = read_bits(byte, 3..0)
  else
    @local_message_type = read_bits(byte, 6..5)
    @time_offset = read_bits(byte, 4..0)
  end
end

Public Instance Methods

data?() click to toggle source
# File lib/fitreader/record_header.rb, line 23
def data?
  @header_type.zero? && @message_type.zero?
end
definition?() click to toggle source
# File lib/fitreader/record_header.rb, line 19
def definition?
  @header_type.zero? && @message_type == 1
end
has_dev_defs?() click to toggle source
# File lib/fitreader/record_header.rb, line 27
def has_dev_defs?
  @message_type_specific == 1
end
timestamp?() click to toggle source
# File lib/fitreader/record_header.rb, line 31
def timestamp?
  @header_type == 1
end