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.

reset

reset() Instance Public methods Resets and initializes the stream. All data

2015-06-14 22:22:09
finished?

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

2015-06-14 22:08:59
avail_in

avail_in() Instance Public methods Returns bytes of data in the input buffer

2015-06-14 21:25:10
stream_end?

stream_end?() Instance Public methods Returns true if the stream is finished

2015-06-14 22:29:29
avail_out=

avail_out=(p1) Instance Public methods Allocates size bytes of

2015-06-14 21:33:31
total_in

total_in() Instance Public methods Returns the total bytes of the input data

2015-06-14 22:30:24
flush_next_out

flush_next_out() Instance Public methods Flushes output buffer and returns all

2015-06-14 22:16:21
data_type

data_type() Instance Public methods Guesses the type of the data which have

2015-06-14 21:43:48
ended?

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

2015-06-14 21:57:33
closed?

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

2015-06-14 21:42:15