Class: Splunk::ConcatenatedStream
- Inherits:
-
IO
- Object
- IO
- Splunk::ConcatenatedStream
- Defined in:
- lib/splunk-sdk-ruby/resultsreader.rb
Overview
Returns a stream which concatenates all the streams passed to it.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(*streams) ⇒ ConcatenatedStream
constructor
A new instance of ConcatenatedStream.
- #read(n = nil) ⇒ Object
Constructor Details
#initialize(*streams) ⇒ ConcatenatedStream
Returns a new instance of ConcatenatedStream.
735 736 737 |
# File 'lib/splunk-sdk-ruby/resultsreader.rb', line 735 def initialize(*streams) @streams = streams end |
Instance Method Details
#close ⇒ Object
739 740 741 742 743 |
# File 'lib/splunk-sdk-ruby/resultsreader.rb', line 739 def close() @streams.each do |stream| stream.close() end end |
#read(n = nil) ⇒ Object
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
# 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 |