class Fit::File::Record

Attributes

content[R]
header[R]

Public Class Methods

clear_definitions!() click to toggle source
# File lib/fit/file/record.rb, line 12
def self.clear_definitions!
  @@definitions.clear
end
read(io) click to toggle source
# File lib/fit/file/record.rb, line 8
def self.read(io)
  new.read(io)
end

Public Instance Methods

read(io) click to toggle source
# File lib/fit/file/record.rb, line 18
def read(io)
  @header = RecordHeader.read(io)

  @content = case @header.message_type.snapshot
  when 1
    Definition.read(io).tap do |definition|
      @@definitions[@header.local_message_type.snapshot] = Data.generate(definition)
    end
  when 0
    definition = @@definitions[@header.local_message_type.snapshot]
    raise "No definition for local message type: #{@header.local_message_type}" if definition.nil?
    definition.read(io)
  end

  self
end