Class: BinData::Transform::Zlib
Overview
Transforms a zlib compressed data stream.
Instance Method Summary
collapse
#before_transform, #num_bytes_remaining, #offset, #prepend_to_chain, #seek_abs, #seekable?, #skip, transform_changes_stream_length!
Constructor Details
#initialize(read_length) ⇒ Zlib
Returns a new instance of Zlib.
9
10
11
12
|
# File 'lib/bindata/transform/zlib.rb', line 9
def initialize(read_length)
super()
@length = read_length
end
|
Instance Method Details
24
25
26
|
# File 'lib/bindata/transform/zlib.rb', line 24
def after_read_transform
raise IOError, "didn't read all data" unless @read.empty?
end
|
28
29
30
|
# File 'lib/bindata/transform/zlib.rb', line 28
def after_write_transform
chain_write(::Zlib::Deflate.deflate(@write))
end
|
#read(n) ⇒ Object
14
15
16
17
|
# File 'lib/bindata/transform/zlib.rb', line 14
def read(n)
@read ||= ::Zlib::Inflate.inflate(chain_read(@length))
@read.slice!(0...n)
end
|
#write(data) ⇒ Object
19
20
21
22
|
# File 'lib/bindata/transform/zlib.rb', line 19
def write(data)
@write ||= create_empty_binary_string
@write << data
end
|