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

Instance Attribute Summary

Attributes inherited from Protocol

#metabuffer, #stowbuffer

Instance Method Summary collapse

Methods inherited from Protocol

#again!, #assemble, #assemble!

Methods included from Arpie

#bogon!, #incomplete!

Constructor Details

#initializeZlibProtocol

Returns a new instance of ZlibProtocol.



356
357
358
359
# File 'lib/arpie/protocol.rb', line 356

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

Instance Method Details

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

Yields:

  • (@inflater.inflate(binary))


365
366
367
368
# File 'lib/arpie/protocol.rb', line 365

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

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

Yields:

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


361
362
363
# File 'lib/arpie/protocol.rb', line 361

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