summaryrefslogtreecommitdiff
path: root/lib/coderay/helpers/gzip.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2011-02-28 23:45:38 +0000
committermurphy <murphy@rubychan.de>2011-02-28 23:45:38 +0000
commitf905c593b0bec7cfb6d65d5f9bdada244c9b7190 (patch)
tree86b9ea51fdeed3b87d1649da19ab7eee0328b38a /lib/coderay/helpers/gzip.rb
parenteb37e370e921dddcc8a1dcccf37badbc2266c1e0 (diff)
downloadcoderay-f905c593b0bec7cfb6d65d5f9bdada244c9b7190.tar.gz
Cleanups (indentation) for GZip helper.
Diffstat (limited to 'lib/coderay/helpers/gzip.rb')
-rw-r--r--lib/coderay/helpers/gzip.rb86
1 files changed, 38 insertions, 48 deletions
diff --git a/lib/coderay/helpers/gzip.rb b/lib/coderay/helpers/gzip.rb
index 43f1000..245014a 100644
--- a/lib/coderay/helpers/gzip.rb
+++ b/lib/coderay/helpers/gzip.rb
@@ -1,51 +1,41 @@
module CodeRay
-
-# =GZip Simple
-#
-# A simplified interface to the gzip library +zlib+ (from the Ruby Standard Library.)
-#
-# Author: murphy (mail to murphy rubychan de)
-#
-# Version: 0.2 (2005.may.28)
-#
-# ==Documentation
-#
-# See +GZip+ module and the +String+ extensions.
-#
-module GZip
-
- require 'zlib'
-
- # The default zipping level. 7 zips good and fast.
- DEFAULT_GZIP_LEVEL = 7
-
- # Unzips the given string +s+.
- #
- # Example:
- # require 'gzip_simple'
- # print GZip.gunzip(File.read('adresses.gz'))
- def GZip.gunzip s
- Zlib::Inflate.inflate s
+
+ # A simplified interface to the gzip library +zlib+ (from the Ruby Standard Library.)
+ module GZip
+
+ require 'zlib'
+
+ # The default zipping level. 7 zips good and fast.
+ DEFAULT_GZIP_LEVEL = 7
+
+ # Unzips the given string +s+.
+ #
+ # Example:
+ # require 'gzip_simple'
+ # print GZip.gunzip(File.read('adresses.gz'))
+ def GZip.gunzip s
+ Zlib::Inflate.inflate s
+ 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:
+ # - 0: no compression, only convert to gzip format
+ # - 1: compress fast
+ # - 7: compress more, but still fast (default)
+ # - 8: compress more, slower
+ # - 9: compress best, very slow
+ def GZip.gzip s, level = DEFAULT_GZIP_LEVEL
+ Zlib::Deflate.new(level).deflate s, Zlib::FINISH
+ end
+
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:
- # - 0: no compression, only convert to gzip format
- # - 1: compress fast
- # - 7: compress more, but still fast (default)
- # - 8: compress more, slower
- # - 9: compress best, very slow
- def GZip.gzip s, level = DEFAULT_GZIP_LEVEL
- Zlib::Deflate.new(level).deflate s, Zlib::FINISH
- end
-end
-
+
end