class Duoconsole::CommandClient

Attributes

socket[R]

Public Class Methods

new(socket) click to toggle source
# File lib/duoconsole.rb, line 69
def initialize socket
  @socket = socket
end

Public Instance Methods

method_missing(m, *args, &block) click to toggle source
# File lib/duoconsole.rb, line 73
def method_missing(m, *args, &block)
  send m, args
end

Private Instance Methods

recv() click to toggle source
# File lib/duoconsole.rb, line 85
def recv
  socket.recv(1000)
rescue IRB::Abort => e
  # IRB::Abort is triggered by ctrl-c
  # When raise, we didn't get to recv message returned from this run
  # Clear it out now so that it won't be in the buffer for next run
  socket.recv(1000)
  raise e
  # e.class.name
end
send(command, args) click to toggle source
# File lib/duoconsole.rb, line 79
def send command, args
  msg = Marshal.dump([command, args])
  socket.write(msg)
  recv
end