Class: Codebot::IPCServer
- Inherits:
-
ThreadController
- Object
- ThreadController
- Codebot::IPCServer
- Defined in:
- lib/codebot/ipc_server.rb
Overview
A pipe-based IPC server used for communicating with a running Codebot instance.
Instance Attribute Summary collapse
-
#core ⇒ Core
readonly
The bot this server belongs to.
-
#pipe ⇒ String
readonly
The path to the named pipe.
Class Method Summary collapse
-
.default_pipe ⇒ String
Returns the path to the default pipe for the current user.
Instance Method Summary collapse
-
#initialize(core, pipe = nil) ⇒ IPCServer
constructor
Creates a new IPC server.
-
#stop ⇒ Thread?
Stops the managed thread if a thread is currently running, then deletes the named pipe.
Methods inherited from ThreadController
#join, #running?, #start, #start!, #stop!
Constructor Details
#initialize(core, pipe = nil) ⇒ IPCServer
Creates a new IPC server.
18 19 20 21 22 |
# File 'lib/codebot/ipc_server.rb', line 18 def initialize(core, pipe = nil) super() @core = core @pipe = pipe || self.class.default_pipe end |
Instance Attribute Details
#core ⇒ Core (readonly)
Returns the bot this server belongs to.
8 9 10 |
# File 'lib/codebot/ipc_server.rb', line 8 def core @core end |
#pipe ⇒ String (readonly)
Returns the path to the named pipe.
11 12 13 |
# File 'lib/codebot/ipc_server.rb', line 11 def pipe @pipe end |
Class Method Details
.default_pipe ⇒ String
Returns the path to the default pipe for the current user.
38 39 40 |
# File 'lib/codebot/ipc_server.rb', line 38 def self.default_pipe File.join Dir.home, '.codebot.ipc' end |
Instance Method Details
#stop ⇒ Thread?
Stops the managed thread if a thread is currently running, then deletes the named pipe.
29 30 31 32 33 |
# File 'lib/codebot/ipc_server.rb', line 29 def stop thr = super delete_pipe thr end |