Class: Duoconsole::CommandServer
- Inherits:
-
Object
- Object
- Duoconsole::CommandServer
- Defined in:
- lib/duoconsole.rb
Constant Summary collapse
- RECOGNIZED_COMMANDS =
[:test, :rake]
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(socket) ⇒ CommandServer
constructor
A new instance of CommandServer.
- #start ⇒ Object
Constructor Details
#initialize(socket) ⇒ CommandServer
Returns a new instance of CommandServer.
146 147 148 |
# File 'lib/duoconsole.rb', line 146 def initialize socket @socket = socket end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
144 145 146 |
# File 'lib/duoconsole.rb', line 144 def socket @socket end |
Instance Method Details
#start ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/duoconsole.rb', line 150 def start loop do msg = socket.recv(1000) command, args = Marshal.load(msg) retval = if valid_command?(command) run_command(command, args) else "Unrecognized command. Valid commands are #{RECOGNIZED_COMMANDS.join(', ')}" end socket.write(retval) end end |