Module: IOExtras::AbstractInputStream

### Home Classes Methods

### In Files

- lib/zip/ioextras.rb

### Methods

- ::new
- #each
- #each_line
- #flush
- #gets
- #read
- #readline
- #readlines

### Included Modules

- Enumerable
- IOExtras::FakeIO

### Class/Module Index

Quicksearch

- Zip
- Zip::ZipCentralDirectory
- Zip::ZipCompressionMethodError
- Zip::ZipDestinationFileExistsError
- Zip::ZipEntry
- Zip::ZipEntryExistsError
- Zip::ZipEntryNameError
- Zip::ZipError
- Zip::ZipExtraField
- Zip::ZipExtraField::Generic
- Zip::ZipExtraField::IUnix
- Zip::ZipExtraField::UniversalTime
- Zip::ZipFile
- Zip::ZipFileSystem
- Zip::ZipFileSystem::ZipFsDir
- Zip::ZipFileSystem::ZipFsFile
- Zip::ZipFileSystem::ZipFsFile::ZipFsStat
- Zip::ZipInputStream
- Zip::ZipInternalError
- Zip::ZipOutputStream
- Zip::ZipStreamableDirectory
- Zip::ZipStreamableStream
- IOExtras
- IOExtras::AbstractInputStream
- IOExtras::AbstractOutputStream
- IOExtras::FakeIO
- BugFix
- Object

No matching classes.

# IOExtras::AbstractInputStream

Implements many of the convenience methods of IO such as gets, getc, readline and readlines depends on: input_finished?, produce_input and read

### Attributes

lineno[RW]

### Public Class Methods

new() click to toggle source

    # File lib/zip/ioextras.rb, line 37
    def initialize
      super
      @lineno = 0
      @outputBuffer = ""
    end

### Public Instance Methods

each(aSepString = $/) click to toggle source
Alias for: each_line
each_line(aSepString = $/) click to toggle source

    # File lib/zip/ioextras.rb, line 108
    def each_line(aSepString = $/)
      while true
        yield readline(aSepString)
      end
    rescue EOFError
    end

Also aliased as: each
flush() click to toggle source

    # File lib/zip/ioextras.rb, line 96
    def flush
      retVal = @outputBuffer
      @outputBuffer=""
      return retVal
    end

gets(aSepString = $/) click to toggle source

    # File lib/zip/ioextras.rb, line 79
    def gets(aSepString = $/)
      @lineno = @lineno.next
      return read if aSepString.nil?
      aSepString = "#{$/}#{$/}" if aSepString.empty?

      bufferIndex = 0
      while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil)
        bufferIndex = @outputBuffer.bytesize
        if input_finished?
          return @outputBuffer.empty? ? nil : flush
        end
        @outputBuffer << produce_input
      end
      sepIndex = matchIndex + aSepString.bytesize
      return @outputBuffer.slice!(0...sepIndex)
    end

read(numberOfBytes = nil, buf = nil) click to toggle source

    # File lib/zip/ioextras.rb, line 45
    def read(numberOfBytes = nil, buf = nil)
      tbuf = nil

      if @outputBuffer.bytesize > 0
        if numberOfBytes <= @outputBuffer.bytesize
          tbuf = @outputBuffer.slice!(0, numberOfBytes)
        else
          numberOfBytes -= @outputBuffer.bytesize 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

readline(aSepString = $/) click to toggle source

    # File lib/zip/ioextras.rb, line 102
    def readline(aSepString = $/)
      retVal = gets(aSepString)
      raise EOFError if retVal == nil
      retVal
    end

readlines(aSepString = $/) click to toggle source

    # File lib/zip/ioextras.rb, line 73
    def readlines(aSepString = $/)
      retVal = []
      each_line(aSepString) { |line| retVal << line }
      retVal
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.