Type:
Class

Zlib::ZStream is the abstract class for the stream which handles the compressed data. The operations are defined in the subclasses: Zlib::Deflate for compression, and Zlib::Inflate for decompression.

An instance of Zlib::ZStream has one stream (struct zstream in the source) and two variable-length buffers which associated to the input (next_in) of the stream and the output (next_out) of the stream. In this document, “input buffer” means the buffer for input, and “output buffer” means the buffer for output.

Data input into an instance of Zlib::ZStream are temporally stored into the end of input buffer, and then data in input buffer are processed from the beginning of the buffer until no more output from the stream is produced (i.e. until #avail_out > 0 after processing). During processing, output buffer is allocated and expanded automatically to hold all output data.

Some particular instance methods consume the data in output buffer and return them as a String.

Here is an ascii art for describing above:

+================ an instance of Zlib::ZStream ================+
||                                                            ||
||     +--------+          +-------+          +--------+      ||
||  +--| output |<---------|zstream|<---------| input  |<--+  ||
||  |  | buffer |  next_out+-------+next_in   | buffer |   |  ||
||  |  +--------+                             +--------+   |  ||
||  |                                                      |  ||
+===|======================================================|===+
    |                                                      |
    v                                                      |
"output data"                                         "input data"

If an error occurs during processing input buffer, an exception which is a subclass of Zlib::Error is raised. At that time, both input and output buffer keep their conditions at the time when the error occurs.

Method Catalogue

Many of the methods in this class are fairly low-level and unlikely to be of interest to users. In fact, users are unlikely to use this class directly; rather they will be interested in Zlib::Inflate and Zlib::Deflate.

The higher level methods are listed below.

ended?

ended?() Instance Public methods Returns true if the stream is closed.

2015-06-14 21:57:33
close

close() Instance Public methods Closes the stream. All operations on the closed

2015-06-14 21:36:50
finish

finish â Stringfinish { |chunk| ... } â nil Instance Public methods

2015-06-14 22:04:42
avail_out

avail_out() Instance Public methods Returns number of bytes of free spaces in

2015-06-14 21:28:44
flush_next_in

flush_next_out â Stringflush_next_out { |chunk| ... } â nil Instance Public methods

2015-06-14 22:12:16
adler

adler() Instance Public methods Returns the adler-32 checksum.

2015-06-14 21:17:54
end

end() Instance Public methods Closes the stream. All operations on the closed

2015-06-14 21:50:48