Class: Weechat::Hooks::CommandRun

Inherits:
Weechat::Hook show all
Defined in:
lib/weechat/hooks/command_run.rb

Instance Attribute Summary

Attributes inherited from Weechat::Hook

#callback, #id

Attributes included from Pointer

#ptr

Instance Method Summary collapse

Methods inherited from Weechat::Hook

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

Methods included from Pointer

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

Constructor Details

#initialize(command, also_arguments = false, &callback) ⇒ CommandRun

Returns a new instance of CommandRunHook

Parameters:

  • also_arguments (Boolean) (defaults to: false)

    If true, two hooks will be made, one for “$command” and one for “$command *”, matching both calls with and without arguments



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/weechat/hooks/command_run.rb', line 9

def initialize(command, also_arguments = false, &callback)
  super
  @command  = if command.is_a? Command
                command.command
              else
                command.to_s
              end

  @callback = EvaluatedCallback.new(callback)
  @ptr      = Weechat.hook_command_run(@command, "command_run_callback", id.to_s)
  if also_arguments
    @ptr2 = Weechat.hook_command_run("#@command *", "command_run_callback", id.to_s)
  end
end

Instance Method Details

#unhook(*args) ⇒ Object



24
25
26
27
# File 'lib/weechat/hooks/command_run.rb', line 24

def unhook(*args)
  super
  self.class.unhook(@ptr2) if @ptr2
end