Class: Burr::Plugin
Overview
steal from jekyll: github.com/mojombo/jekyll/blob/master/lib/jekyll/plugin.rb
Direct Known Subclasses
AsidePlugin, CodeblockPlugin, FigurePlugin, LinkPlugin, ParserPlugin, TablePlugin, TocPlugin
Constant Summary collapse
- PRIORITIES =
{ :lowest => -100, :low => -10, :normal => 0, :high => 10, :highest => 100 }
- VALIDS =
[:before_parse, :after_parse, :before_decorate, :after_decorate]
Instance Attribute Summary collapse
-
#book ⇒ Object
Returns the value of attribute book.
Class Method Summary collapse
-
.<=>(other) ⇒ Object
Spaceship is priority [higher -> lower].
-
.inherited(base) ⇒ Object
Install a hook so that subclasses are recorded.
-
.priority(priority = nil) ⇒ Object
Get or set the priority of this plugin.
-
.subclasses ⇒ Object
The list of Classes that have been subclassed.
Instance Method Summary collapse
-
#initialize(book) ⇒ Plugin
constructor
Initialize a new plugin.
Constructor Details
#initialize(book) ⇒ Plugin
Initialize a new plugin. This should be overridden by the subclass.
book - The book object.
Returns a new instance.
65 66 67 |
# File 'lib/burr/plugin.rb', line 65 def initialize(book) @book = book end |
Instance Attribute Details
#book ⇒ Object
Returns the value of attribute book.
58 59 60 |
# File 'lib/burr/plugin.rb', line 58 def book @book end |
Class Method Details
.<=>(other) ⇒ Object
Spaceship is priority [higher -> lower]
other - The class to be compared.
Returns -1, 0, 1.
52 53 54 |
# File 'lib/burr/plugin.rb', line 52 def <=>(other) PRIORITIES[other.priority] <=> PRIORITIES[self.priority] end |
.inherited(base) ⇒ Object
Install a hook so that subclasses are recorded. This method is only ever called by Ruby itself.
20 21 22 23 |
# File 'lib/burr/plugin.rb', line 20 def inherited(base) subclasses << base subclasses.sort! end |
.priority(priority = nil) ⇒ Object
Get or set the priority of this plugin. When called without an argument it returns the priority. When an argument is given, it will set the priority.
39 40 41 42 43 44 45 |
# File 'lib/burr/plugin.rb', line 39 def priority(priority=nil) @priority ||= nil if priority && PRIORITIES.has_key?(priority) @priority = priority end @priority || :normal end |
.subclasses ⇒ Object
The list of Classes that have been subclassed.
28 29 30 |
# File 'lib/burr/plugin.rb', line 28 def subclasses @subclasses ||= [] end |