class RubyTDMS::AggregateChannelEnumerator
Public Class Methods
new(channels)
click to toggle source
# File lib/ruby_tdms/aggregate_channel_enumerator.rb, line 6 def initialize(channels) @channels = channels @offsets = [] size = 0 @channels.inject(0) do |size, channel| @offsets << size size += channel.values.size end end
Public Instance Methods
[](i)
click to toggle source
# File lib/ruby_tdms/aggregate_channel_enumerator.rb, line 30 def [](i) if (i < 0) || (i >= size) raise RangeError, 'Channel %s has a range of 0 to %d, got invalid index: %d' % [@channels[0].path, size - 1, i] end channel, offset = nil, nil j = @offsets.size - 1 @offsets.reverse_each do |o| if i >= o channel = @channels[j] offset = @offsets[j] break else j -= 1 end end channel.values[i - offset] end
each() { |value| ... }
click to toggle source
# File lib/ruby_tdms/aggregate_channel_enumerator.rb, line 23 def each @channels.each do |channel| channel.values.each { |value| yield value } end end
size()
click to toggle source
# File lib/ruby_tdms/aggregate_channel_enumerator.rb, line 18 def size @size ||= @channels.inject(0) { |sum, chan| sum += chan.values.size } end