class RubyTDMS::ChannelEnumerator

Public Class Methods

new(channel) click to toggle source
# File lib/ruby_tdms/channel_enumerator.rb, line 6
def initialize(channel)
        @channel = channel
end

Public Instance Methods

[](i) click to toggle source
# File lib/ruby_tdms/channel_enumerator.rb, line 21
def [](i)
        if (i < 0) || (i >= size)
                raise RangeError, 'Channel %s has a range of 0 to %d, got invalid index: %d' % [@channel.path, size - 1, i]
        end

        chunk_index = i / @channel.chunk_value_count

        offset = (@channel.raw_data_offset + (@channel.chunk_length * chunk_index)) + (i * @channel.value_offset)
        @channel.stream.seek offset
        @channel.data_type.read_from_stream(@channel.stream, @channel.segment.big_endian?).value
end
each() { |self| ... } click to toggle source
# File lib/ruby_tdms/channel_enumerator.rb, line 16
def each
        0.upto(size - 1) { |i| yield self[i] }
end
size() click to toggle source
# File lib/ruby_tdms/channel_enumerator.rb, line 11
def size
        @size ||= @channel.value_count
end