Class: FileHeader
- Inherits:
-
Object
- Object
- FileHeader
- Defined in:
- lib/fitreader/file_header.rb
Instance Attribute Summary collapse
-
#crc ⇒ Object
Returns the value of attribute crc.
-
#header_size ⇒ Object
Returns the value of attribute header_size.
-
#num_records ⇒ Object
Returns the value of attribute num_records.
-
#profile_version ⇒ Object
Returns the value of attribute profile_version.
-
#protocol_version ⇒ Object
Returns the value of attribute protocol_version.
-
#valid_file ⇒ Object
Returns the value of attribute valid_file.
Instance Method Summary collapse
-
#initialize(bytes) ⇒ FileHeader
constructor
A new instance of FileHeader.
- #to_s ⇒ Object
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
#crc ⇒ Object
Returns the value of attribute crc.
2 3 4 |
# File 'lib/fitreader/file_header.rb', line 2 def crc @crc end |
#header_size ⇒ Object
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_records ⇒ Object
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_version ⇒ Object
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_version ⇒ Object
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_file ⇒ Object
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_s ⇒ Object
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 |