class Ciphr::Functions::ZLib::Gzip
Public Class Methods
params()
click to toggle source
# File lib/ciphr/functions/zlib.rb, line 91 def self.params [:input] end
variants()
click to toggle source
# File lib/ciphr/functions/zlib.rb, line 85 def self.variants [ [['gzip','gz'], {}] ] end
Public Instance Methods
apply()
click to toggle source
# File lib/ciphr/functions/zlib.rb, line 53 def apply input = @args[0] sio = StringIO.new sio.binmode gz = !invert ? Zlib::GzipWriter.new(UncloseableIOProxy.new(sio)) : Zlib::GzipReader.new(input) Proc.new do if invert # unzip gz.read(256) else # zip chunk = input.read(256) if chunk gz.write chunk sio.rewind ret = sio.read sio.rewind sio.truncate(0) ret elsif gz gz.close gz = nil sio.rewind ret = sio.read sio.rewind sio.truncate(0) ret else nil end end end end