Sha256: ef77d4a1d1b119aaa68c24f233c122ad0c91ea156a19197e47ba2d00606cd50d

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

module Fit
  class File
    class Record

      @@definitions = {}
      cattr_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} in #{@@definitions}" if definition.nil?
          definition.read(io) unless definition.nil?
        end

        self
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
garmin-fit-0.0.2 lib/fit/file/record.rb