Sha256: d28da12834a032aabe34e413271a6c1b28429cb67a95ab55b043109e2dd2b1d1

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

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

      def initialize(definitions, dev_definitions)
        @definitions = definitions
        @dev_definitions = dev_definitions
      end

      def read(io)
        @header = RecordHeader.read(io)

        @content = case @header.message_type.snapshot
        when 1
          Definition.read(io, { dev_data_flag: @header.dev_data_flag }).tap do |definition|
            if @header.dev_data_flag == 1
              @definitions[@header.local_message_type.snapshot] = Data.generate(definition, @dev_definitions)
            else
              @definitions[@header.local_message_type.snapshot] = Data.generate(definition)
            end
          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

10 entries across 10 versions & 1 rubygems

Version Path
fit_parser-1.0.9 lib/fit_parser/file/record.rb
fit_parser-1.0.8 lib/fit_parser/file/record.rb
fit_parser-1.0.7 lib/fit_parser/file/record.rb
fit_parser-1.0.6 lib/fit_parser/file/record.rb
fit_parser-1.0.5 lib/fit_parser/file/record.rb
fit_parser-1.0.4 lib/fit_parser/file/record.rb
fit_parser-1.0.3 lib/fit_parser/file/record.rb
fit_parser-1.0.2 lib/fit_parser/file/record.rb
fit_parser-1.0.1 lib/fit_parser/file/record.rb
fit_parser-1.0.0 lib/fit_parser/file/record.rb