Module: HrrRbSsh::Transport::CompressionAlgorithm::Functionable
- Includes:
- Loggable
- Included in:
- Zlib
- Defined in:
- lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb
Instance Attribute Summary
Attributes included from Loggable
#log_key, #logger
Instance Method Summary
collapse
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Instance Method Details
#close ⇒ Object
31
32
33
34
|
# File 'lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb', line 31
def close
@deflator.close if @deflator && @deflator.closed?.!
@inflator.close if @inflator && @inflator.closed?.!
end
|
#deflate(data) ⇒ Object
23
24
25
|
# File 'lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb', line 23
def deflate data
@deflator.deflate(data, ::Zlib::SYNC_FLUSH)
end
|
#inflate(data) ⇒ Object
27
28
29
|
# File 'lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb', line 27
def inflate data
@inflator.inflate(data)
end
|
#initialize(direction, logger: nil) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb', line 13
def initialize direction, logger: nil
self.logger = logger
case direction
when Direction::OUTGOING
@deflator = ::Zlib::Deflate.new
when Direction::INCOMING
@inflator = ::Zlib::Inflate.new
end
end
|