Class: LiveF1::Packet::Sys::Commentary
- Inherits:
-
LiveF1::Packet::Sys
- Object
- LiveF1::Packet
- LiveF1::Packet::Sys
- LiveF1::Packet::Sys::Commentary
- Includes:
- Decryptable, Type::Long
- Defined in:
- lib/live_f1/packet/sys/commentary.rb
Instance Attribute Summary
Attributes included from Decryptable
Attributes inherited from LiveF1::Packet
Instance Method Summary collapse
-
#line ⇒ Object
Returns the line of commentary, which may only be a partial line if this commentary was split over multiple packets.
-
#terminal? ⇒ Boolean
Is this the last line of this commentary string?.
- #to_s ⇒ Object
Methods included from Decryptable
Methods included from Type::Long
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
#line ⇒ Object
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
13 14 15 |
# File 'lib/live_f1/packet/sys/commentary.rb', line 13 def terminal? data.bytes.to_a[1] == 1 end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/live_f1/packet/sys/commentary.rb', line 27 def to_s "%s%s" % [line, (terminal? ? "" : "…")] end |