Class: Fit::File::Record
- Inherits:
-
Object
- Object
- Fit::File::Record
- Defined in:
- lib/fit/file/record.rb
Constant Summary collapse
- @@definitions =
{}
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
16 17 18 |
# File 'lib/fit/file/record.rb', line 16 def content @content end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
16 17 18 |
# File 'lib/fit/file/record.rb', line 16 def header @header end |
Class Method Details
.clear_definitions! ⇒ Object
12 13 14 |
# File 'lib/fit/file/record.rb', line 12 def self.clear_definitions! @@definitions.clear end |
.read(io) ⇒ Object
8 9 10 |
# File 'lib/fit/file/record.rb', line 8 def self.read(io) new.read(io) end |
Instance Method Details
#read(io) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fit/file/record.rb', line 18 def read(io) @header = RecordHeader.read(io) @content = case @header..snapshot when 1 Definition.read(io).tap do |definition| @@definitions[@header..snapshot] = Data.generate(definition) end when 0 definition = @@definitions[@header..snapshot] # raise "No definition for local message type: #{@header} in #{@@definitions}" if definition.nil? definition.read(io) unless definition.nil? end self end |