Class: PasteHub::PluginClass
- Inherits:
-
Object
- Object
- PasteHub::PluginClass
- Defined in:
- lib/pastehub/plugin.rb
Instance Attribute Summary collapse
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
Instance Method Summary collapse
- #display_config ⇒ Object
- #distribute_newly_arrived(message) ⇒ Object
-
#initialize ⇒ PluginClass
constructor
A new instance of PluginClass.
- #load_plugin_dir(dir) ⇒ Object
- #load_plugins ⇒ Object
- #register_plugin(obj) ⇒ Object
Constructor Details
#initialize ⇒ PluginClass
Returns a new instance of PluginClass.
38 39 40 |
# File 'lib/pastehub/plugin.rb', line 38 def initialize @plugins = [] end |
Instance Attribute Details
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
36 37 38 |
# File 'lib/pastehub/plugin.rb', line 36 def plugins @plugins end |
Instance Method Details
#display_config ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pastehub/plugin.rb', line 42 def display_config @plugins.each {|x| STDERR.printf( "Info: plugin [%s] loaded.\n", x.class.to_s ) x.display_config() } end |
#distribute_newly_arrived(message) ⇒ Object
69 70 71 72 73 |
# File 'lib/pastehub/plugin.rb', line 69 def distribute_newly_arrived() @plugins.each { |obj| obj.newly_arrived() } end |
#load_plugin_dir(dir) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/pastehub/plugin.rb', line 55 def load_plugin_dir(dir) dir = File.(dir) Dir.entries(dir).sort.each {|filename| if filename =~ /\.rb$/ require File.join(dir, filename) end } nil end |
#load_plugins ⇒ Object
49 50 51 52 53 |
# File 'lib/pastehub/plugin.rb', line 49 def load_plugins dir = File.join(File.dirname(__FILE__), "plugin") load_plugin_dir(dir) nil end |
#register_plugin(obj) ⇒ Object
65 66 67 |
# File 'lib/pastehub/plugin.rb', line 65 def register_plugin(obj) @plugins << obj end |