Class: LiveF1::Source::Log

Inherits:
LiveF1::Source show all
Defined in:
lib/live_f1/source/log.rb

Instance Attribute Summary collapse

Attributes inherited from LiveF1::Source

#session

Instance Method Summary collapse

Methods inherited from LiveF1::Source

#decrypt, #read_packet, #run

Constructor Details

#initialize(file) ⇒ Log

Returns a new instance of Log.



9
10
11
12
13
# File 'lib/live_f1/source/log.rb', line 9

def initialize file
  @file = file
  @data = YAML.load(@file.read)
  @bytes = StringIO.new(@data[:bytes])
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/live_f1/source/log.rb', line 7

def data
  @data
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/live_f1/source/log.rb', line 7

def file
  @file
end

Instance Method Details

#decryption_key(session_number) ⇒ Object



24
25
26
# File 'lib/live_f1/source/log.rb', line 24

def decryption_key session_number
  data[:key].to_i
end

#keyframe(number = nil) ⇒ Object



19
20
21
22
# File 'lib/live_f1/source/log.rb', line 19

def keyframe number = nil
  keyframe_data = data[:keyframes][number.to_s] || ""
  Source::Keyframe.new StringIO.new(keyframe_data), self
end

#read_bytes(num) ⇒ Object



15
16
17
# File 'lib/live_f1/source/log.rb', line 15

def read_bytes num
  @bytes.read(num)
end