Sha256: 8e3c11009ebca7a7963232c5f04af143c3a0ee85a278b5ca7e61b2eb1e6b4314

Contents?: true

Size: 737 Bytes

Versions: 3

Compression:

Stored size: 737 Bytes

Contents

module FitParser
  class File
    class Record
      attr_reader :header, :content, :definitions

      def initialize(definitions)
        @definitions = definitions
      end

      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]
          fail "No definition for local message type: #{@header.local_message_type}" if definition.nil?
          definition.read(io)
        end

        self
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fit_parser-0.0.8 lib/fit_parser/file/record.rb
fit_parser-0.0.7 lib/fit_parser/file/record.rb
fit_parser-0.0.6 lib/fit_parser/file/record.rb