Class: PasteHub::PluginClass

Inherits:
Object
  • Object
show all
Defined in:
lib/pastehub/plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePluginClass

Returns a new instance of PluginClass.



38
39
40
# File 'lib/pastehub/plugin.rb', line 38

def initialize
  @plugins = []
end

Instance Attribute Details

#pluginsObject (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_configObject



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(message)
  @plugins.each { |obj|
    obj.newly_arrived(message)
  }
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.expand_path(dir)
  Dir.entries(dir).sort.each {|filename|
    if filename =~ /\.rb$/
      require File.join(dir, filename)
    end
  }
  nil
end

#load_pluginsObject



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