Class: LiveF1::Packet::Sys::Speed

Inherits:
LiveF1::Packet::Sys show all
Includes:
Decryptable, Type::Long
Defined in:
lib/live_f1/packet/sys/speed.rb

Instance Attribute Summary

Attributes included from Decryptable

#raw_data

Attributes inherited from LiveF1::Packet

#data, #header, #source

Instance Method Summary collapse

Methods included from Decryptable

#bytes, #data=

Methods included from Type::Long

#length, #spare_bits

Methods inherited from LiveF1::Packet

from_source, #initialize, #inspect, #leader, #spare_bits, #spare_data

Constructor Details

This class inherits a constructor from LiveF1::Packet

Instance Method Details

#speedsObject



12
13
14
# File 'lib/live_f1/packet/sys/speed.rb', line 12

def speeds
  data[1..-1].split(/\s+/).each_slice(2).map { |d,s| "%s: %d" % [d,s] }.join(", ")
end

#to_sObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/live_f1/packet/sys/speed.rb', line 16

def to_s
  out = case trap
  when 1..4
    speeds
  else
    data[1..-1]
  end

  "[%d] %s" % [trap, out]
end

#trapObject



8
9
10
# File 'lib/live_f1/packet/sys/speed.rb', line 8

def trap
  data.bytes.first
end