Class: Ciphr::Functions::ZLib::Deflate
Instance Attribute Summary
#invert
Attributes inherited from Function
#args, #options
Class Method Summary
collapse
Instance Method Summary
collapse
invertable?
Methods inherited from Function
aligned, inherited, #initialize, invertable?, #prepend, #read
Class Method Details
.params ⇒ Object
32
33
34
|
# File 'lib/ciphr/functions/zlib.rb', line 32
def self.params
[:input]
end
|
.variants ⇒ Object
26
27
28
29
30
|
# File 'lib/ciphr/functions/zlib.rb', line 26
def self.variants
[
[['deflate'], {}]
]
end
|
Instance Method Details
#apply ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/ciphr/functions/zlib.rb', line 5
def apply
input = @args[0]
zstream = invert ? Zlib::Inflate.new : Zlib::Deflate.new
Proc.new do
chunk = input.read(256)
if chunk
if invert
zstream.inflate(chunk)
else
zstream.deflate(chunk,Zlib::SYNC_FLUSH)
end
else
begin
ensure
zstream.close
end
end
end
end
|