Flowdock

This module provides access to the zlib library. Zlib is designed to be a portable, free, general-purpose, legally unencumbered – that is, not covered by any patents – lossless data-compression library for use on virtually any computer hardware and operating system.

The zlib compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data.

The zlib compressed data format is described in RFC 1950, which is a wrapper around a deflate stream which is described in RFC 1951.

The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of IO. The gzip format is described in RFC 1952 which is also a wrapper around a deflate stream.

The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single-file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib.

See your system’s zlib.h for further information about zlib

Sample usage

Using the wrapper to compress strings with default parameters is quite simple:

require "zlib"

data_to_compress = File.read("don_quixote.txt")

puts "Input size: #{data_to_compress.size}"
#=> Input size: 2347740

data_compressed = Zlib::Deflate.deflate(data_to_compress)

puts "Compressed size: #{data_compressed.size}"
#=> Compressed size: 887238

uncompressed_data = Zlib::Inflate.inflate(data_compressed)

puts "Uncompressed data is: #{uncompressed_data}"
#=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...

Class tree

(if you have GZIP_SUPPORT)

Constants

OS_UNKNOWN = INT2FIX(OS_UNKNOWN)

OS_RISCOS = INT2FIX(OS_RISCOS)

OS_QDOS = INT2FIX(OS_QDOS)

OS_CPM = INT2FIX(OS_CPM)

OS_ZSYSTEM = INT2FIX(OS_ZSYSTEM)

OS_VMCMS = INT2FIX(OS_VMCMS)

OS_WIN32 = INT2FIX(OS_WIN32)

OS_TOPS20 = INT2FIX(OS_TOPS20)

OS_MACOS = INT2FIX(OS_MACOS)

OS_OS2 = INT2FIX(OS_OS2)

OS_ATARI = INT2FIX(OS_ATARI)

OS_UNIX = INT2FIX(OS_UNIX)

OS_VMS = INT2FIX(OS_VMS)

OS_AMIGA = INT2FIX(OS_AMIGA)

OS_MSDOS = INT2FIX(OS_MSDOS)

OS_CODE = INT2FIX(OS_CODE)

FINISH = INT2FIX(Z_FINISH)

FULL_FLUSH = INT2FIX(Z_FULL_FLUSH)

SYNC_FLUSH = INT2FIX(Z_SYNC_FLUSH)

NO_FLUSH = INT2FIX(Z_NO_FLUSH)

MAX_MEM_LEVEL = INT2FIX(MAX_MEM_LEVEL)

DEF_MEM_LEVEL = INT2FIX(DEF_MEM_LEVEL)

MAX_WBITS = The maximum size of the zlib history buffer. Note that zlib allows larger values to enable different inflate modes. See Zlib:

DEFAULT_STRATEGY = INT2FIX(Z_DEFAULT_STRATEGY)

FIXED = INT2FIX(Z_FIXED)

RLE = INT2FIX(Z_RLE)

HUFFMAN_ONLY = INT2FIX(Z_HUFFMAN_ONLY)

FILTERED = INT2FIX(Z_FILTERED)

DEFAULT_COMPRESSION = INT2FIX(Z_DEFAULT_COMPRESSION)

BEST_COMPRESSION = INT2FIX(Z_BEST_COMPRESSION)

BEST_SPEED = INT2FIX(Z_BEST_SPEED)

NO_COMPRESSION = INT2FIX(Z_NO_COMPRESSION)

UNKNOWN = Represents an unknown data type as guessed by deflate. See Zlib:

TEXT = Represents text data as guessed by deflate. See Zlib:

ASCII = Represents text data as guessed by deflate. NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT in zlib 1.2.2. New applications should not use this constant. See Zlib:

BINARY = Represents binary data as guessed by deflate. See Zlib:

ZLIB_VERSION = rb_str_new2(ZLIB_VERSION)

VERSION = rb_str_new2(RUBY_ZLIB_VERSION)

Attributes

Show files where this module is defined (1 file)
Register or log in to add new notes.