Module: GZIP

Defined in:
lib/archive.rb

Class Method Summary collapse

Class Method Details

.compress(string, level) ⇒ Object



5
6
7
8
9
10
# File 'lib/archive.rb', line 5

def self.compress string, level
  z = Zlib::Deflate.new level
  dst = z.deflate string, Zlib::FINISH
  z.close
  dst
end

.decompress(string) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/archive.rb', line 12

def self.decompress string
  zstream = Zlib::Inflate.new
  buf = zstream.inflate string
  zstream.finish
  zstream.close
  buf
end