Class: Arpie::ZlibProtocol

Inherits:
Protocol show all
Defined in:
lib/arpie/protocol.rb

Overview

A transparent zlib stream de/compression protocol.

Constant Summary

Constants inherited from Protocol

Protocol::CAN_SEPARATE_MESSAGES

Constants included from Arpie

MTU, VERSION

Instance Method Summary collapse

Methods inherited from Protocol

#assemble, #assemble!

Methods included from Arpie

#bogon!, #incomplete!

Constructor Details

#initializeZlibProtocol

Returns a new instance of ZlibProtocol.



340
341
342
343
# File 'lib/arpie/protocol.rb', line 340

def initialize
  @inflater = Zlib::Inflate.new
  @deflater = Zlib::Deflate.new
end

Instance Method Details

#from(binary) {|@inflater.inflate(binary)| ... } ⇒ Object

Yields:

  • (@inflater.inflate(binary))


349
350
351
352
# File 'lib/arpie/protocol.rb', line 349

def from binary
  yield @inflater.inflate(binary)
  binary.size
end

#to(object) {|@deflater.deflate(object) + @deflater.flush| ... } ⇒ Object

Yields:

  • (@deflater.deflate(object) + @deflater.flush)


345
346
347
# File 'lib/arpie/protocol.rb', line 345

def to object
  yield @deflater.deflate(object) + @deflater.flush
end