Class: Fitreader::FitFile

Inherits:
Object
  • Object
show all
Defined in:
lib/fitreader/fitfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FitFile



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fitreader/fitfile.rb', line 13

def initialize(path)
  if path.is_a? String
    @file = File.open(path, 'rb')
  elsif path.is_a? File
    @file = path
  end
  @header = FileHeader.new(@file.read(14))
  if valid?
    @defs = {}
    @messages = {}
    process_next_record while @file.pos < @header.num_records
  end
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



11
12
13
# File 'lib/fitreader/fitfile.rb', line 11

def file
  @file
end

#headerObject (readonly)

Returns the value of attribute header.



11
12
13
# File 'lib/fitreader/fitfile.rb', line 11

def header
  @header
end

#messagesObject (readonly)

Returns the value of attribute messages.



11
12
13
# File 'lib/fitreader/fitfile.rb', line 11

def messages
  @messages
end