Class: IRTelemetry::IBTFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ir_telemetry/ibt_file.rb

Constant Summary collapse

IRSDK_HEADER_SIZE =
112
IRSDK_VAR_HEADER_SIZE =
144
IRSDK_MAX_STRING =
32
IRSDK_MAX_DESC =
64
IBT_FILE_ENCODING =
"Windows-1252"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ IBTFile

Returns a new instance of IBTFile.



27
28
29
30
# File 'lib/ir_telemetry/ibt_file.rb', line 27

def initialize(filepath)
  @io = File.open(filepath, "rb")
  @header = Headers::IRSDKHeader.read(@io)
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



8
9
10
# File 'lib/ir_telemetry/ibt_file.rb', line 8

def header
  @header
end

#ioObject (readonly)

Returns the value of attribute io.



8
9
10
# File 'lib/ir_telemetry/ibt_file.rb', line 8

def io
  @io
end

Class Method Details

.open(filepath, &block) ⇒ Object



19
20
21
22
23
24
# File 'lib/ir_telemetry/ibt_file.rb', line 19

def open(filepath, &block)
  io = new(filepath)
  block.call(io)
ensure
  io&.close
end

Instance Method Details

#closeObject



32
33
34
# File 'lib/ir_telemetry/ibt_file.rb', line 32

def close
  @io.close
end

#datasetObject



45
46
47
# File 'lib/ir_telemetry/ibt_file.rb', line 45

def dataset
  @dataset ||= Dataset.new(self)
end

#session_infoObject



36
37
38
39
40
41
42
43
# File 'lib/ir_telemetry/ibt_file.rb', line 36

def session_info
  @io.seek(@header.session_info_offset)
  session_string = @io.read(@header.session_info_len)
  session_string.force_encoding(IBT_FILE_ENCODING)
  session_string.encode("UTF-8")

  YAML.safe_load(session_string, permitted_classes: [Date])
end