Class: FitParser::File::Record
- Inherits:
-
Object
- Object
- FitParser::File::Record
- Defined in:
- lib/fit_parser/file/record.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
-
#initialize(definitions, dev_definitions) ⇒ Record
constructor
A new instance of Record.
- #read(io) ⇒ Object
Constructor Details
#initialize(definitions, dev_definitions) ⇒ Record
Returns a new instance of Record.
6 7 8 9 |
# File 'lib/fit_parser/file/record.rb', line 6 def initialize(definitions, dev_definitions) @definitions = definitions @dev_definitions = dev_definitions end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/fit_parser/file/record.rb', line 4 def content @content end |
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
4 5 6 |
# File 'lib/fit_parser/file/record.rb', line 4 def definitions @definitions end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
4 5 6 |
# File 'lib/fit_parser/file/record.rb', line 4 def header @header end |
Instance Method Details
#read(io) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fit_parser/file/record.rb', line 11 def read(io) @header = RecordHeader.read(io) @content = case @header..snapshot when 1 Definition.read(io, { dev_data_flag: @header.dev_data_flag }).tap do |definition| if @header.dev_data_flag == 1 @definitions[@header..snapshot] = Data.generate(definition, @dev_definitions) else @definitions[@header..snapshot] = Data.generate(definition) end end when 0 definition = @definitions[@header..snapshot] fail "No definition for local message type: #{@header.}" if definition.nil? definition.read(io) end self end |