Class: FileHeader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytes) ⇒ FileHeader

Returns a new instance of FileHeader.



5
6
7
8
9
10
11
12
# File 'lib/fitreader/file_header.rb', line 5

def initialize(bytes)
  @header_size = bytes[0].unpack('C').first
  @protocol_version = bytes[1].unpack('C').first
  @profile_version = bytes[2..3].unpack('v').first
  @num_records = bytes[4..7].unpack('V').first
  @valid_file = bytes[8..11] == ".FIT"
  @crc = bytes[12..13].unpack('v').first
end

Instance Attribute Details

#crcObject

Returns the value of attribute crc.



2
3
4
# File 'lib/fitreader/file_header.rb', line 2

def crc
  @crc
end

#header_sizeObject

Returns the value of attribute header_size.



2
3
4
# File 'lib/fitreader/file_header.rb', line 2

def header_size
  @header_size
end

#num_recordsObject

Returns the value of attribute num_records.



2
3
4
# File 'lib/fitreader/file_header.rb', line 2

def num_records
  @num_records
end

#profile_versionObject

Returns the value of attribute profile_version.



2
3
4
# File 'lib/fitreader/file_header.rb', line 2

def profile_version
  @profile_version
end

#protocol_versionObject

Returns the value of attribute protocol_version.



2
3
4
# File 'lib/fitreader/file_header.rb', line 2

def protocol_version
  @protocol_version
end

#valid_fileObject

Returns the value of attribute valid_file.



2
3
4
# File 'lib/fitreader/file_header.rb', line 2

def valid_file
  @valid_file
end

Instance Method Details

#to_sObject



14
15
16
# File 'lib/fitreader/file_header.rb', line 14

def to_s
  "size: #{header_size}, proto_v: #{protocol_version}, prof_v: #{profile_version}, records: #{num_records}"
end