Class: LiveF1::Packet::Sys::Commentary

Inherits:
LiveF1::Packet::Sys show all
Includes:
Decryptable, Type::Long
Defined in:
lib/live_f1/packet/sys/commentary.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

#lineObject

Returns the line of commentary, which may only be a partial line if this commentary was split over multiple packets



19
20
21
22
23
24
25
# File 'lib/live_f1/packet/sys/commentary.rb', line 19

def line
      # The commentary packet encoding used to be all messed up. Its UTF-8
      # characters were treated as Windows-1252 and then reconverted back
      # to UTF-8. We used to fix that but now the issue has been
      # corrected.
	data[2..-1].force_encoding("UTF-8")#.encode("Windows-1252").force_encoding("UTF-8")
end

#terminal?Boolean

Is this the last line of this commentary string?

If not, the next packet should also be a Commentary packet continuing this text

Returns:

  • (Boolean)


13
14
15
# File 'lib/live_f1/packet/sys/commentary.rb', line 13

def terminal?
	data.bytes.to_a[1] == 1
end

#to_sObject



27
28
29
# File 'lib/live_f1/packet/sys/commentary.rb', line 27

def to_s
	"%s%s" % [line, (terminal? ? "" : "")]
end