Sha256: ee180c29d6563177f43750969bfd6975029af96a99db4815ba9db2b1b0157bd5

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

module FitParser
  class File
    class Record

      @@definitions = {}
      mattr_reader :definitions, instance_reader: false

      def self.read(io)
        new.read(io)
      end

      def self.clear_definitions!
        @@definitions.clear
      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|
            @@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

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fit_parser-0.0.4 lib/fit_parser/file/record.rb
fit_parser-0.0.2 lib/fit_parser/file/record.rb
fit_parser-0.0.1 lib/fit_parser/file/record.rb