Module | IOExtras::AbstractInputStream |
In: |
lib/zip/ioextras.rb
|
lineno | [RW] |
# File lib/zip/ioextras.rb, line 108 def each_line(aSepString = $/) while true yield readline(aSepString) end rescue EOFError end
# File lib/zip/ioextras.rb, line 96 def flush retVal=@outputBuffer @outputBuffer="" return retVal end
# File lib/zip/ioextras.rb, line 79 def gets(aSepString=$/) @lineno = @lineno.next return read if aSepString == nil aSepString="#{$/}#{$/}" if aSepString == "" bufferIndex=0 while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil) bufferIndex=@outputBuffer.length if input_finished? return @outputBuffer.empty? ? nil : flush end @outputBuffer << produce_input end sepIndex=matchIndex + aSepString.length return @outputBuffer.slice!(0...sepIndex) end
# File lib/zip/ioextras.rb, line 45 def read(numberOfBytes = nil, buf = nil) tbuf = nil if @outputBuffer.length > 0 if numberOfBytes <= @outputBuffer.length tbuf = @outputBuffer.slice!(0, numberOfBytes) else numberOfBytes -= @outputBuffer.length if (numberOfBytes) rbuf = sysread(numberOfBytes, buf) tbuf = @outputBuffer tbuf << rbuf if (rbuf) @outputBuffer = "" end else tbuf = sysread(numberOfBytes, buf) end return nil unless (tbuf) if buf buf.replace(tbuf) else buf = tbuf end buf end
# File lib/zip/ioextras.rb, line 102 def readline(aSepString = $/) retVal = gets(aSepString) raise EOFError if retVal == nil return retVal end