Class: Henshin::Plugin
- Inherits:
-
Object
- Object
- Henshin::Plugin
- Defined in:
- lib/henshin/plugin.rb
Instance Attribute Summary collapse
-
#config ⇒ Hash{Symbol => Object}
The config for the plugin.
-
#extensions ⇒ Hash{:input, :output => Array, String}
The file extensions that can be read by the plugin and the extension of the output.
-
#priority ⇒ Integer
The plugins are sorted on priority, high priority plugins are called first.
Class Method Summary collapse
-
.subclasses ⇒ Array
Finds all classes that subclass this particular class.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Plugins are sorted by priority.
-
#initialize(site) ⇒ Plugin
constructor
Create a new instance of Plugin.
Constructor Details
#initialize(site) ⇒ Plugin
Create a new instance of Plugin
27 28 29 30 31 32 |
# File 'lib/henshin/plugin.rb', line 27 def initialize(site) @extensions = {:input => [], :output => ''} @config = {} @priority = 3 end |
Instance Attribute Details
#config ⇒ Hash{Symbol => Object}
Returns the config for the plugin.
17 18 19 |
# File 'lib/henshin/plugin.rb', line 17 def config @config end |
#extensions ⇒ Hash{:input, :output => Array, String}
Returns the file extensions that can be read by the plugin and the extension of the output.
13 14 15 |
# File 'lib/henshin/plugin.rb', line 13 def extensions @extensions end |
#priority ⇒ Integer
Returns The plugins are sorted on priority, high priority plugins are called first. You could really use any number, but stick to 1 to 5.
22 23 24 |
# File 'lib/henshin/plugin.rb', line 22 def priority @priority end |
Class Method Details
.subclasses ⇒ Array
Finds all classes that subclass this particular class
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/henshin/plugin.rb', line 39 def self.subclasses r = Henshin.constants.find_all do |c_klass| if (c_klass != c_klass.upcase) && (Henshin.const_get(c_klass).is_a?(Class)) self > Henshin.const_get(c_klass) else nil end end r.collect {|k| Henshin.const_get(k)} end |
Instance Method Details
#<=>(other) ⇒ Object
Plugins are sorted by priority
51 52 53 |
# File 'lib/henshin/plugin.rb', line 51 def <=>(other) self.priority <=> other.priority end |