class Splunk::ConcatenatedStream

Returns a stream which concatenates all the streams passed to it.

Public Class Methods

new(*streams) click to toggle source
# File lib/splunk-sdk-ruby/resultsreader.rb, line 735
def initialize(*streams)
  @streams = streams
end

Public Instance Methods

close() click to toggle source
# File lib/splunk-sdk-ruby/resultsreader.rb, line 739
def close()
  @streams.each do |stream|
    stream.close()
  end
end
read(n=nil) click to toggle source
# File lib/splunk-sdk-ruby/resultsreader.rb, line 745
def read(n=nil)
  response = ""
  while n.nil? or n > 0
    if @streams.empty? # No streams left
      break
    else # We have streams left.
      chunk = @streams[0].read(n) || ""
      found_n = chunk.length()
      if n.nil? or chunk.length() < n
        @streams.shift()
      end
      if !n.nil?
        n -= chunk.length()
      end

      response << chunk
    end
  end
  if response == ""
    return nil
  else
    return response
  end
end