Class: Jeti::Log::Data::CompositeDatasetBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/jeti/log/data/composite_dataset_builder.rb

Class Method Summary collapse

Class Method Details

.build(file, clazz, device, primary, *others) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jeti/log/data/composite_dataset_builder.rb', line 5

def self.build(file, clazz, device, primary, *others)
  primaries = if primary.is_a? Array
                file.value_dataset(device, primary[0], primary[1])
              else
                file.value_dataset(device, primary)
              end

  other_data = others.map do |other|
    if other.is_a? Array
      file.value_dataset(device, other[0], other[1])
    else
      file.value_dataset(device, other)
    end
  end

  primaries.map do |raw|
    time = raw[0]
    f0 = raw[1]
    fn = other_data.map { |d| d.min_by { |dp| (dp[0] - time).abs }[1] }
    clazz.new(time, fn.unshift(f0))
  end
end