Class: Arpie::YAMLProtocol

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

Overview

A protocol which encodes objects into YAML representation. Messages are arbitary yaml-encodable objects.

Constant Summary collapse

CAN_SEPARATE_MESSAGES =
true

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!

Instance Method Details

#from(binary) {|YAML.load(binary[0, index])| ... } ⇒ Object

Yields:

  • (YAML.load(binary[0, index]))


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

def from binary
  index = binary =~ /^\.\.\.$/x or incomplete!
  yield YAML.load(binary[0, index])
  4 + index
end

#to(object) {|YAML.dump(object) + "...\n"| ... } ⇒ Object

Yields:

  • (YAML.dump(object) + "...\n")


343
344
345
# File 'lib/arpie/protocol.rb', line 343

def to object
  yield YAML.dump(object) + "...\n"
end