Class: RecordHeader
- Defined in:
- lib/fitreader/record_header.rb
Constant Summary
Constants included from Unpack
Instance Attribute Summary collapse
-
#header_type ⇒ Object
Returns the value of attribute header_type.
-
#local_message_type ⇒ Object
Returns the value of attribute local_message_type.
-
#message_type ⇒ Object
Returns the value of attribute message_type.
-
#message_type_specific ⇒ Object
Returns the value of attribute message_type_specific.
-
#time_offset ⇒ Object
Returns the value of attribute time_offset.
Instance Method Summary collapse
- #data? ⇒ Boolean
- #definition? ⇒ Boolean
-
#initialize(io) ⇒ RecordHeader
constructor
A new instance of RecordHeader.
- #timestamp? ⇒ Boolean
Methods inherited from FitObject
Methods included from Unpack
#read_bit, #read_bits, #read_multiple, #readbytes
Constructor Details
#initialize(io) ⇒ RecordHeader
Returns a new instance of RecordHeader.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fitreader/record_header.rb', line 4 def initialize(io) byte = io.readbyte @header_type = read_bit(byte, 7) # 0 = normal, 1 = timestamp if @header_type.zero? @message_type = read_bit(byte, 6) # 1 = definition, 0 = data @message_type_specific = read_bit(byte, 5) # 1 = developer fields @reserved = read_bit(byte, 4) @local_message_type = read_bits(byte, 3..0) else @local_message_type = read_bits(byte, 6..5) @time_offset = read_bits(byte, 4..0) end end |
Instance Attribute Details
#header_type ⇒ Object
Returns the value of attribute header_type.
2 3 4 |
# File 'lib/fitreader/record_header.rb', line 2 def header_type @header_type end |
#local_message_type ⇒ Object
Returns the value of attribute local_message_type.
2 3 4 |
# File 'lib/fitreader/record_header.rb', line 2 def @local_message_type end |
#message_type ⇒ Object
Returns the value of attribute message_type.
2 3 4 |
# File 'lib/fitreader/record_header.rb', line 2 def @message_type end |
#message_type_specific ⇒ Object
Returns the value of attribute message_type_specific.
2 3 4 |
# File 'lib/fitreader/record_header.rb', line 2 def @message_type_specific end |
#time_offset ⇒ Object
Returns the value of attribute time_offset.
2 3 4 |
# File 'lib/fitreader/record_header.rb', line 2 def time_offset @time_offset end |
Instance Method Details
#data? ⇒ Boolean
23 24 25 |
# File 'lib/fitreader/record_header.rb', line 23 def data? @header_type.zero? && @message_type.zero? end |
#definition? ⇒ Boolean
19 20 21 |
# File 'lib/fitreader/record_header.rb', line 19 def definition? @header_type.zero? && @message_type == 1 end |
#timestamp? ⇒ Boolean
27 28 29 |
# File 'lib/fitreader/record_header.rb', line 27 def @header_type == 1 end |