Class: Weechat::Plugin

Inherits:
Object show all
Extended by:
Properties
Includes:
Pointer
Defined in:
lib/weechat/plugin.rb

Overview

Gettable properties

filename

Filename of the plugin

handle

?

name

Name of the plugin

description

Description of the plugin

author

Author of the plugin

version

Version of the plugin

license

Licence of the plugin

charset

?

debug?

?

Instance Attribute Summary

Attributes included from Pointer

#ptr

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Weechat::Properties::ClassMethods

#apply_transformation, #init_properties, #known_integer_properties, #known_properties, #known_string_properties, #mappings, #rtransformations, #settable_properties, #transformations, #type

Methods included from Pointer

#==, #hash, #initialize, #inspect, #to_s

Class Method Details

.find_by_name(name) ⇒ Object Also known as: find



29
30
31
32
33
34
# File 'lib/weechat/plugin.rb', line 29

def find_by_name(name)
  if name.nil? or name.empty? or name == "core"
    return Plugin.new("")
  end
  plugins.find {|plugin| plugin.name == name}
end

.load(name) ⇒ void

This method returns an undefined value.

Loads a plugin.



49
50
51
# File 'lib/weechat/plugin.rb', line 49

def load(name)
  Weechat.exec("/plugin load #{name}")
end

.pluginsObject Also known as: all



37
38
39
40
41
42
43
# File 'lib/weechat/plugin.rb', line 37

def plugins
  plugins = [Plugin.new("")]
  Weechat::Infolist.parse("plugin").each do |plugin|
    plugins << Plugin.new(plugin[:pointer])
  end
  plugins
end

.reload_allArray<Plugin>

Reloads all plugins.

Note: This will not reload the ruby plugin.

Returns:

  • (Array<Plugin>)

    All plugins that have been reloaded.



58
59
60
61
# File 'lib/weechat/plugin.rb', line 58

def reload_all
  plugins = all.select{|plugin| plugin.name != "ruby"}
  plugins.each {|plugin| plugin.reload}
end

Instance Method Details

#nameObject



64
65
66
# File 'lib/weechat/plugin.rb', line 64

def name
  Weechat.plugin_get_name(@ptr)
end

#reload(force = false) ⇒ Boolean

Reload the plugin.

Parameters:

  • force (Boolean) (defaults to: false)

    If the plugin to be reloaded is “ruby”, force has to be true.

Returns:

  • (Boolean)

    true if we attempted to reload the plugin



87
88
89
90
91
92
93
# File 'lib/weechat/plugin.rb', line 87

def reload(force = false)
  if name == "ruby" and !force
    Weechat.puts "Won't reload the ruby plugin unless you force it."
  else
    Weechat.exec("/plugin reload #{name}")
  end
end

#scriptsArray<Script>

Returns an array of all scripts loaded by this plugin.

Returns:



98
99
100
101
102
103
104
# File 'lib/weechat/plugin.rb', line 98

def scripts
  scripts = []
  Infolist.parse("#{name}_script").each do |script|
    scripts << Script.new(script[:pointer], self)
  end
  scripts
end

#unload(force = false) ⇒ Boolean

Unloads the plugin.

Parameters:

  • force (Boolean) (defaults to: false)

    If the plugin to be unloaded is “ruby”, force has to be true.

Returns:

  • (Boolean)

    true if we attempted to unload the plugin



73
74
75
76
77
78
79
80
81
# File 'lib/weechat/plugin.rb', line 73

def unload(force = false)
  if name == "ruby" and !force
    Weechat.puts "Won't unload the ruby plugin unless you force it."
    false
  else
    Weechat.exec("/plugin unload #{name}")
    true
  end
end