Class: Dalli::GzipCompressor

Inherits:
Object
  • Object
show all
Defined in:
lib/dalli/compressor.rb

Class Method Summary collapse

Class Method Details

.compress(data) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/dalli/compressor.rb', line 17

def self.compress(data)
  io = StringIO.new(String.new(""), "w")
  gz = Zlib::GzipWriter.new(io)
  gz.write(data)
  gz.close
  io.string
end

.decompress(data) ⇒ Object


25
26
27
28
# File 'lib/dalli/compressor.rb', line 25

def self.decompress(data)
  io = StringIO.new(data, "rb")
  Zlib::GzipReader.new(io).read
end