Sha256: e6fe31800c69cd4d8f98305dd5ce20bcf1c50de31134386392e11f92894803c1

Contents?: true

Size: 527 Bytes

Versions: 2

Compression:

Stored size: 527 Bytes

Contents

module Kabuki
  class Zip
    def initialize(string)
      @string = string
    end
    
    def compress(level=3)
      z = Zlib::Deflate.new(level)
      dst = z.deflate(@string, Zlib::FINISH)
      z.close
      dst
    end

    def decompress
      zstream = Zlib::Inflate.new
      buf = zstream.inflate(@string)
      zstream.finish
      zstream.close
      buf
    end
  end
end

class String
  def kabuki_zip
    Kabuki::Zip.new(self).compress
  end
  
  def kabuki_unzip
    Kabuki::Zip.new(self).decompress
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kabuki-0.0.3 lib/kabuki/zip.rb
kabuki-0.0.1 lib/kabuki/zip.rb