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

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) {|Shellwords.shellwords(binary)| ... } ⇒ Object

Yields:

  • (Shellwords.shellwords(binary))


333
334
335
# File 'lib/arpie/protocol.rb', line 333

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)


327
328
329
330
331
# File 'lib/arpie/protocol.rb', line 327

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