Class: Cinch::PluginList

Inherits:
Array
  • Object
show all
Defined in:
lib/cinch/plugin_list.rb

Overview

Since:

  • 2.0.0

Instance Method Summary collapse

Constructor Details

#initialize(bot) ⇒ PluginList

Returns a new instance of PluginList.

Since:

  • 2.0.0



6
7
8
9
# File 'lib/cinch/plugin_list.rb', line 6

def initialize(bot)
  @bot = bot
  super()
end

Instance Method Details

#register_plugin(plugin) ⇒ Object

Parameters:

Since:

  • 2.0.0



12
13
14
# File 'lib/cinch/plugin_list.rb', line 12

def register_plugin(plugin)
  self << plugin.new(@bot)
end

#register_plugins(plugins) ⇒ Object

Parameters:

  • plugins (Array<Class<Plugin>>)

Since:

  • 2.0.0



17
18
19
# File 'lib/cinch/plugin_list.rb', line 17

def register_plugins(plugins)
  plugins.each { |plugin| register_plugin(plugin) }
end

#unregister_allObject

Since:

  • 2.0.0



36
37
38
# File 'lib/cinch/plugin_list.rb', line 36

def unregister_all
  unregister_plugins(self)
end

#unregister_plugin(plugin) ⇒ Object

Since:

  • 2.0.0



22
23
24
25
# File 'lib/cinch/plugin_list.rb', line 22

def unregister_plugin(plugin)
  plugin.unregister
  delete(plugin)
end

#unregister_plugins(plugins) ⇒ Object

Since:

  • 2.0.0



28
29
30
31
32
33
# File 'lib/cinch/plugin_list.rb', line 28

def unregister_plugins(plugins)
  if plugins == self
    plugins = dup
  end
  plugins.each { |plugin| unregister_plugin(plugin) }
end