Sha256: 3fe26fa7342a3c0f2c2eb0543f619c1860c91621ebd9753f107a3f918efecf64

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

module FitParser
  class File
    class Record
      def self.read(io)
        new.read(io)
      end

      def self.clear_definitions!
        @definitions = {}
      end

      def self.definitions=(value)
        @definitions = value
      end

      def self.definitions
        @definitions
      end

      attr_reader :header, :content

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

        @content = case @header.message_type.snapshot
        when 1
          Definition.read(io).tap do |definition|
            Record.definitions[@header.local_message_type.snapshot] = Data.generate(definition)
          end
        when 0
          definition = Record.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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fit_parser-0.0.5 lib/fit_parser/file/record.rb