Class: Weechat::Plugin

Inherits:
Object
  • 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

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

Methods included from Pointer

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

Class Method Details

.allObject



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

def all
  items = super
  items[0,0] = Plugin.find("")
  items
end

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



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

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

.load(name) ⇒ void

This method returns an undefined value.

Loads a plugin.



46
47
48
# File 'lib/weechat/plugin.rb', line 46

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

.reload_allArray<Plugin>

Reloads all plugins.

Note: This will not reload the ruby plugin.

Returns:

  • (Array<Plugin>)

    All plugins that have been reloaded.



55
56
57
58
# File 'lib/weechat/plugin.rb', line 55

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

Instance Method Details

#nameObject



61
62
63
# File 'lib/weechat/plugin.rb', line 61

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



84
85
86
87
88
89
90
# File 'lib/weechat/plugin.rb', line 84

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:



95
96
97
98
99
100
101
# File 'lib/weechat/plugin.rb', line 95

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



70
71
72
73
74
75
76
77
78
# File 'lib/weechat/plugin.rb', line 70

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