Class: FitParser::File
- Inherits:
-
Object
- Object
- FitParser::File
- Defined in:
- lib/fit_parser/file.rb,
lib/fit_parser/file/data.rb,
lib/fit_parser/file/type.rb,
lib/fit_parser/file/types.rb,
lib/fit_parser/file/header.rb,
lib/fit_parser/file/record.rb,
lib/fit_parser/file/definition.rb,
lib/fit_parser/file/definitions.rb,
lib/fit_parser/file/record_header.rb
Defined Under Namespace
Modules: Definitions, Types Classes: Data, Definition, Header, Record, RecordHeader, Type
Constant Summary collapse
- MSG_NUM_FIELD_DESCRIPTION =
206
Instance Attribute Summary collapse
-
#crc ⇒ Object
readonly
Returns the value of attribute crc.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ File
constructor
A new instance of File.
- #read(io) ⇒ Object
Constructor Details
#initialize ⇒ File
Returns a new instance of File.
11 12 13 |
# File 'lib/fit_parser/file.rb', line 11 def initialize @records = [] end |
Instance Attribute Details
#crc ⇒ Object (readonly)
Returns the value of attribute crc.
9 10 11 |
# File 'lib/fit_parser/file.rb', line 9 def crc @crc end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
9 10 11 |
# File 'lib/fit_parser/file.rb', line 9 def header @header end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
9 10 11 |
# File 'lib/fit_parser/file.rb', line 9 def records @records end |
Class Method Details
.read(io) ⇒ Object
5 6 7 |
# File 'lib/fit_parser/file.rb', line 5 def self.read(io) new.read(io) end |
Instance Method Details
#read(io) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fit_parser/file.rb', line 15 def read(io) @header = Header.read(io) definitions = {} dev_definitions = {} while io.pos < @header.end_pos record = Record.new(definitions, dev_definitions) @records << record.read(io) content = record.content if content[:global_message_number] == MSG_NUM_FIELD_DESCRIPTION = record.header. end if !content[:global_message_number] && && record.header. == dev_definitions[content[:raw_field_0].to_s] ||= {} dev_definitions[content[:raw_field_0].to_s][content[:raw_field_1].to_s] = content end definitions = record.definitions end @crc = io.read(2) self end |