Module: Zlib

Module | Zlib
In: | lib/more/facets/zlib.rb

A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.

### Methods

compress decompress deflate inflate

### Public Class methods

compress(source)

Compresses a string using gzip.

[Source]

    # File lib/more/facets/zlib.rb, line 16
      def self.compress(source)
        output = StringIO.new
        class << output
          def close; rewind; end
        end
        gz = GzipWriter.new(output)
        gz.write(source)
        gz.close
        output.string
      end

decompress(source)

Decompresses a gzipped string.

[Source]

    # File lib/more/facets/zlib.rb, line 11
      def self.decompress(source)
        GzipReader.new(StringIO.new(source)).read
      end

deflate(string, level=DEFAULT_COMPRESSION)

Deflate a string.

[Source]

    # File lib/more/facets/zlib.rb, line 33
      def self.deflate(string, level=DEFAULT_COMPRESSION)
        Deflate.deflate(string, level)
      end

inflate(string)

Inflate a deflated sting.

[Source]

    # File lib/more/facets/zlib.rb, line 28
      def self.inflate(string)
        Inflate.inflate(string)
      end

[Validate]