Class: OPQ::PluginLoader
- Inherits:
-
Object
- Object
- OPQ::PluginLoader
- Defined in:
- lib/opqr/plugin.rb
Instance Attribute Summary collapse
-
#plugins ⇒ Object
Returns the value of attribute plugins.
Instance Method Summary collapse
Instance Attribute Details
#plugins ⇒ Object
Returns the value of attribute plugins.
9 10 11 |
# File 'lib/opqr/plugin.rb', line 9 def plugins @plugins end |
Instance Method Details
#load_all(plugin_dir) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/opqr/plugin.rb', line 10 def load_all(plugin_dir) puts "[BOT] 正在加载插件,请稍等~" @plugins = [] Dir.glob(File.join(plugin_dir, '*.rb')).each do |plugin_file| $LOAD_PATH.unshift(plugin_dir) Kernel.load(plugin_file) plugin_name = File.basename(plugin_file, '.rb').capitalize plugin_class = Object.const_get("#{plugin_name}") @plugins << plugin_class.new end puts "[BOT] 插件加载完毕!" + @plugins.map { |p| p.class.name}.to_s end |