Class: Spektrum::Log::Record
- Inherits:
-
Object
- Object
- Spektrum::Log::Record
- Defined in:
- lib/spektrum/log/records.rb
Overview
Represents a single record from the telemetry file.
Direct Known Subclasses
AltimeterRecord, BasicDataRecord, FlightLogRecord, GForceRecord, GPSRecord1, GPSRecord2, MysteryRecord, SpeedRecord
Instance Attribute Summary collapse
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(timestamp, raw_data) ⇒ Record
constructor
A new instance of Record.
-
#raw_hex_string ⇒ String
Gets the 32-bit segmented hex string of the raw data for this record.
- #type ⇒ Object
-
#valid? ⇒ Boolean
Determines if this record should be considered valid.
Constructor Details
#initialize(timestamp, raw_data) ⇒ Record
Returns a new instance of Record.
9 10 11 12 13 14 15 |
# File 'lib/spektrum/log/records.rb', line 9 def initialize(, raw_data) if raw_data.length != 16 raise ArgumentError, "raw_data incorrectly sized (#{raw_data.length})" end = @raw_data = raw_data end |
Instance Attribute Details
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/spektrum/log/records.rb', line 7 def end |
Instance Method Details
#raw_hex_string ⇒ String
Gets the 32-bit segmented hex string of the raw data for this record.
20 21 22 |
# File 'lib/spektrum/log/records.rb', line 20 def raw_hex_string @raw_hex_string ||= @raw_data.unpack('H*')[0].gsub(/(.{8})(?=.)/, '\1 \2') end |
#type ⇒ Object
24 25 26 |
# File 'lib/spektrum/log/records.rb', line 24 def type @type ||= byte_field(0) end |
#valid? ⇒ Boolean
Determines if this record should be considered valid. Definitions of valid will vary by the type of record.
32 33 34 |
# File 'lib/spektrum/log/records.rb', line 32 def valid? true end |