Class: Codebot::IPCClient

Inherits:
Object
  • Object
show all
Defined in:
lib/codebot/ipc_client.rb

Overview

A pipe-based IPC client used for communicating with a running Codebot instance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipe = nil) ⇒ IPCClient

Creates a new IPC client.

Parameters:

  • pipe (String) (defaults to: nil)

    the path to the named pipe, or nil to use the default pipe for this user



16
17
18
# File 'lib/codebot/ipc_client.rb', line 16

def initialize(pipe = nil)
  @pipe = pipe || IPCServer.default_pipe
end

Instance Attribute Details

#pipeString (readonly)

Returns the path to the named pipe.

Returns:

  • (String)

    the path to the named pipe



10
11
12
# File 'lib/codebot/ipc_client.rb', line 10

def pipe
  @pipe
end

Instance Method Details

#pipe_exist?Boolean

Checks whether the named pipe exists.

Returns:

  • (Boolean)

    true if the pipe exists, false otherwise



37
38
39
# File 'lib/codebot/ipc_client.rb', line 37

def pipe_exist?
  File.pipe? @pipe
end

#send_rehash(explicit = true) ⇒ Object

Sends a REHASH command to the named pipe.

Parameters:

  • explicit (Boolean) (defaults to: true)

    whether this command was invoked explicitly



23
24
25
# File 'lib/codebot/ipc_client.rb', line 23

def send_rehash(explicit = true)
  command('REHASH', explicit)
end

#send_stop(explicit = true) ⇒ Object

Sends a STOP command to the named pipe.

Parameters:

  • explicit (Boolean) (defaults to: true)

    whether this command was invoked explicitly



30
31
32
# File 'lib/codebot/ipc_client.rb', line 30

def send_stop(explicit = true)
  command('STOP', explicit)
end