Class: Weechat::Process

Inherits:
Hook
  • Object
show all
Defined in:
lib/weechat/process.rb

Instance Attribute Summary collapse

Attributes inherited from Hook

#callback, #id

Attributes included from Pointer

#ptr

Instance Method Summary collapse

Methods inherited from Hook

all, #call, compute_free_id, find_by_id, #hooked?, inherited, init, register, #unhook, unhook, unhook_all, unregister

Methods included from Pointer

#==, #hash, included, #inspect, #to_s

Constructor Details

#initialize(command, timeout = 0, collect = false, &callback) ⇒ Process

Returns a new instance of Process.



10
11
12
13
14
15
16
17
# File 'lib/weechat/process.rb', line 10

def initialize(command, timeout = 0, collect = false, &callback)
  super
  @command  = command
  @collect  = collect
  @stdout, @stderr = [], []
  @callback = EvaluatedCallback.new(callback)
  @ptr      = Weechat.hook_process(command, timeout, "process_callback", id.to_s)
end

Instance Attribute Details

#collectObject (readonly) Also known as: collect?

Returns a new instance of Process

Parameters:

  • command (String)

    Command to execute

  • timeout (Integer)

    Timeout after which to terminate the process

  • collect (Boolean)

    If true, buffer output until process ends



9
10
11
# File 'lib/weechat/process.rb', line 9

def collect
  @collect
end

Instance Method Details

#buffer(stdout, stderr) ⇒ Object



28
29
30
31
# File 'lib/weechat/process.rb', line 28

def buffer(stdout, stderr)
  @stdout << stdout
  @stderr << stderr
end

#stderrObject



24
25
26
# File 'lib/weechat/process.rb', line 24

def stderr
  @stderr.join("")
end

#stdoutObject



20
21
22
# File 'lib/weechat/process.rb', line 20

def stdout
  @stdout.join("")
end