Class: Spektrum::Log::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/spektrum/log/records.rb

Overview

Represents a single record from the telemetry file.

Instance Attribute Summary collapse

Instance Method Summary collapse

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(timestamp, raw_data)
  if raw_data.length != 16
    raise ArgumentError, "raw_data incorrectly sized (#{raw_data.length})"
  end
  @timestamp = timestamp
  @raw_data = raw_data
end

Instance Attribute Details

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/spektrum/log/records.rb', line 7

def timestamp
  @timestamp
end

Instance Method Details

#raw_hex_stringString

Gets the 32-bit segmented hex string of the raw data for this record.

Returns:

  • (String)

    raw hex string for the 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

#typeObject



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.

Returns:

  • (Boolean)

    true if the record is valid, false otherwise



32
33
34
# File 'lib/spektrum/log/records.rb', line 32

def valid?
  true
end