Module: LiveF1::Packet::SectorTime

Included in:
Car::Period1, Car::Period2, Car::Period3, Car::Sector1, Car::Sector2, Car::Sector3
Defined in:
lib/live_f1/packet/sector_time.rb

Constant Summary collapse

COLORS =

Note of which bits appear in packet headers to represent different coloured sectors TODO: Use these colours somewhere

{
  0b010 => :red,
  0b110 => :yellow,
  0b001 => :white,
  0b100 => :purple,
  0b011 => :green
}

Instance Method Summary collapse

Instance Method Details

#secondsObject



16
17
18
19
20
21
# File 'lib/live_f1/packet/sector_time.rb', line 16

def seconds
  if match = data.match(/^(?:(\d+):)?(\d+.\d+)$/)
    _, minutes, seconds = match.to_a
    (Rational(minutes.to_i * 60) + Rational(seconds)).to_f
  end
end

#to_sObject



23
24
25
# File 'lib/live_f1/packet/sector_time.rb', line 23

def to_s
  seconds || data
end