Module | CodeRay::GZip |
In: |
lib/coderay/helpers/gzip.rb
|
A simplified interface to the gzip library zlib (from the Ruby Standard Library.)
DEFAULT_GZIP_LEVEL | = | 7 | The default zipping level. 7 zips good and fast. |
Unzips the given string s.
Example:
require 'gzip_simple' print GZip.gunzip(File.read('adresses.gz'))
# File lib/coderay/helpers/gzip.rb, line 16 16: def GZip.gunzip s 17: Zlib::Inflate.inflate s 18: end
Zips the given string s.
Example:
require 'gzip_simple' File.open('adresses.gz', 'w') do |file file.write GZip.gzip('Mum: 0123 456 789', 9) end
If you provide a level, you can control how strong the string is compressed:
# File lib/coderay/helpers/gzip.rb, line 35 35: def GZip.gzip s, level = DEFAULT_GZIP_LEVEL 36: Zlib::Deflate.new(level).deflate s, Zlib::FINISH 37: end