Sha256: 86fb2f901aa4316764bda661bf8c5d59d4efb4e63650a6ea77ab5d65d39b8fc9

Contents?: true

Size: 587 Bytes

Versions: 1

Compression:

Stored size: 587 Bytes

Contents

module LZO
  # TODO: surely there's a better way to do this that i'm not aware of
  class MultiIO
    def initialize(ios)
      @ios = ios
    end

    def read(nbytes = nil)
      output = StringIO.new ''.force_encoding('BINARY')

      while nbytes.nil? || output.length < nbytes
        io = @ios.first
        break if io.nil?
        read_len = (nbytes - output.length) if nbytes
        bytes = io.read read_len
        @ios.shift if io.eof?
        output.write bytes
      end

      output.rewind
      output.read
    end

    def eof?
      @ios.length == 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lzo-0.1.0 lib/lzo/multi_io.rb