Class: Fit::File

Inherits:
Object
  • Object
show all
Defined in:
lib/fit/file.rb,
lib/fit/file/data.rb,
lib/fit/file/header.rb,
lib/fit/file/record.rb,
lib/fit/file/definition.rb,
lib/fit/file/definitions.rb,
lib/fit/file/record_header.rb

Defined Under Namespace

Modules: Definitions Classes: Data, Definition, Header, Record, RecordHeader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFile

Returns a new instance of File.



10
11
12
# File 'lib/fit/file.rb', line 10

def initialize
  @records = []
end

Instance Attribute Details

#crcObject (readonly)

Returns the value of attribute crc.



8
9
10
# File 'lib/fit/file.rb', line 8

def crc
  @crc
end

#headerObject (readonly)

Returns the value of attribute header.



8
9
10
# File 'lib/fit/file.rb', line 8

def header
  @header
end

#recordsObject (readonly)

Returns the value of attribute records.



8
9
10
# File 'lib/fit/file.rb', line 8

def records
  @records
end

Class Method Details

.read(io) ⇒ Object



4
5
6
# File 'lib/fit/file.rb', line 4

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

Instance Method Details

#read(io) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fit/file.rb', line 14

def read(io)
  @header = Header.read(io)

  Record.clear_definitions!

  while io.pos < @header.end_pos
    @records << Record.read(io)
  end

  @crc = io.read(2)

  self
end