Class: Arpie::ShellwordsProtocol

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

Overview

A linebased-protocol, which does shellwords-escaping/joining on the lines; messages sent are arrays of parameters. Note that all parameters are expected to be strings.

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!

Instance Method Details

#from(binary) {|Shellwords.shellwords(binary)| ... } ⇒ Object

Yields:

  • (Shellwords.shellwords(binary))


320
321
322
# File 'lib/arpie/protocol.rb', line 320

def from binary
  yield Shellwords.shellwords(binary)
end

#to(object) {|Shellwords.join(object.map {|x| x.to_s })| ... } ⇒ Object

Yields:

  • (Shellwords.join(object.map {|x| x.to_s }))

Raises:

  • (ArgumentError)


314
315
316
317
318
# File 'lib/arpie/protocol.rb', line 314

def to object
  raise ArgumentError, "#{self.class.to_s} can only encode arrays." unless
    object.is_a?(Array)
  yield Shellwords.join(object.map {|x| x.to_s })
end