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

Instance Method Summary collapse

Methods inherited from Protocol

#again!, #assemble, #assemble!, #bogon!, #gulp!, #incomplete!

Instance Method Details

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

Yields:

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


367
368
369
370
371
# File 'lib/arpie/protocol.rb', line 367

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

#to(object) ⇒ Object



363
364
365
# File 'lib/arpie/protocol.rb', line 363

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