Class: Kabuki::Zip
Instance Method Summary collapse
- #compress(level = 3) ⇒ Object
- #decompress ⇒ Object
-
#initialize(string) ⇒ Zip
constructor
A new instance of Zip.
Constructor Details
#initialize(string) ⇒ Zip
Returns a new instance of Zip.
3 4 5 |
# File 'lib/kabuki/zip.rb', line 3 def initialize(string) @string = string end |
Instance Method Details
#compress(level = 3) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/kabuki/zip.rb', line 7 def compress(level=3) z = Zlib::Deflate.new(level) dst = z.deflate(@string, Zlib::FINISH) z.close dst end |
#decompress ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/kabuki/zip.rb', line 14 def decompress zstream = Zlib::Inflate.new buf = zstream.inflate(@string) zstream.finish zstream.close buf end |