class RHC::Vendor::Zlib::ZStream

Public Class Methods

new() click to toggle source
# File lib/rhc/vendor/zliby.rb, line 57
def initialize
  @input_buffer = []
  @output_buffer = []
  @out_pos = -1
  @in_pos = -1
  @bit_bucket = 0
  @bit_count = 0

end

Public Instance Methods

adler() click to toggle source

Returns the adler-32 checksum of the input data.

# File lib/rhc/vendor/zliby.rb, line 67
def adler
end
avail_in() click to toggle source

Returns the number of bytes read. Normally 0 since all bytes are read at once.

# File lib/rhc/vendor/zliby.rb, line 71
def avail_in
  @input_buffer.length - @in_pos
end
avail_out() click to toggle source

Returns number of free bytes in the output buffer. As the output buffer is self expanding this normally returns 0.

# File lib/rhc/vendor/zliby.rb, line 76
def avail_out
  @output_buffer.length - @out_pos
end
avail_out=(size) click to toggle source

Allocates size bytes in output buffer. If size < #avail_out it truncates the buffer.

# File lib/rhc/vendor/zliby.rb, line 81
def avail_out= size
  size.times do 
    if size > avail_out
      @output_buffer.push nil
    else
      @output_buffer.pop
    end
  end
end
close() click to toggle source

Closes stream. Further operations will raise Zlib::StreamError

# File lib/rhc/vendor/zliby.rb, line 92
def close
  @closed = true
end
closed?() click to toggle source

True if stream closed, otherwise False.

# File lib/rhc/vendor/zliby.rb, line 97
def closed?
  @closed
end
data_type() click to toggle source

Best guess of input data, one of Zlib::BINARY, Zlib::ASCII, or Zlib::UNKNOWN

# File lib/rhc/vendor/zliby.rb, line 102
def data_type
end
end() click to toggle source

See close

# File lib/rhc/vendor/zliby.rb, line 106
def end
  close
end
ended?() click to toggle source

See closed?

# File lib/rhc/vendor/zliby.rb, line 111
def ended?
  closed?
end
finish() click to toggle source

Finishes the stream, flushes output buffer, implemented by child classes

# File lib/rhc/vendor/zliby.rb, line 116
def finish
  close
end
finished?() click to toggle source

True if stream is finished, otherwise False

# File lib/rhc/vendor/zliby.rb, line 121
def finished?
  if @finished.nil? then
    false
  else
    @finished
  end
end
flush_next_in() click to toggle source

Flushes input buffer and returns the data therein.

# File lib/rhc/vendor/zliby.rb, line 130
def flush_next_in
  @in_pos = @input_buffer.length
  @finished = true
  ret = @input_buffer.pack("c*")
  @input_buffer = []
  ret
end
flush_next_out() click to toggle source

Flushes the output buffer and returns all the data

# File lib/rhc/vendor/zliby.rb, line 139
def flush_next_out
  @out_pos = @output_buffer.length
  @finished = true
  ret = @output_buffer.pack("c*")
  @output_buffer = []
  ret
end
reset() click to toggle source

Reset stream. Input and Output buffers are reset.

# File lib/rhc/vendor/zliby.rb, line 148
def reset
  @out_pos = -1
  @in_pos = -1
  @input_buffer = []
  @output_buffer = []
end
stream_end?() click to toggle source

See finished.

# File lib/rhc/vendor/zliby.rb, line 156
def stream_end?
  finished?
end
total_in() click to toggle source

Size of input buffer.

# File lib/rhc/vendor/zliby.rb, line 161
def total_in
  @input_buffer.length
end
total_out() click to toggle source

Size of output buffer.

# File lib/rhc/vendor/zliby.rb, line 166
def total_out
  @output_buffer.length
end