Class: IRTelemetry::Dataset

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/ir_telemetry/dataset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Dataset

Returns a new instance of Dataset.



12
13
14
15
# File 'lib/ir_telemetry/dataset.rb', line 12

def initialize(file)
  @file = file
  @variables = set_variables
end

Instance Attribute Details

#variablesObject (readonly)

Returns the value of attribute variables.



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

def variables
  @variables
end

Instance Method Details

#[](index) ⇒ Object



17
18
19
20
21
22
# File 'lib/ir_telemetry/dataset.rb', line 17

def [](index)
  io.seek(buffer_offset + index * buffer_length)

  buffer = io.read(buffer_length)
  DataPoint.new(buffer, self)
end

#each(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/ir_telemetry/dataset.rb', line 24

def each(&block)
  start_at_the_beginning

  while (buffer = io.read(buffer_length))
    data_point = DataPoint.new(buffer, self)

    yield data_point if block
  end
end