Class: Weechat::Process

Inherits:
Hook 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

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

Methods included from Pointer

#==, #hash, #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)

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



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

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

#stderrObject



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

def stderr
  @stderr.join("")
end

#stdoutObject



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

def stdout
  @stdout.join("")
end