Class: ActiveTools::CoreExtension::Kabuki::Zip
- Inherits:
-
Object
- Object
- ActiveTools::CoreExtension::Kabuki::Zip
- Defined in:
- lib/active_tools/core_extension/kabuki/zip.rb
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.
6 7 8 |
# File 'lib/active_tools/core_extension/kabuki/zip.rb', line 6 def initialize(string) @string = string end |
Instance Method Details
#compress(level = 3) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/active_tools/core_extension/kabuki/zip.rb', line 10 def compress(level=3) z = Zlib::Deflate.new(level) dst = z.deflate(@string, Zlib::FINISH) z.close dst end |
#decompress ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/active_tools/core_extension/kabuki/zip.rb', line 17 def decompress zstream = Zlib::Inflate.new buf = zstream.inflate(@string) zstream.finish zstream.close buf end |