Class: Howl::Plugin

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

Direct Known Subclasses

Converter

Constant Summary collapse

PRIORITIES =
{ :lowest => -100,
:low => -10,
:normal => 0,
:high => 10,
:highest => 100 }

Class Method Summary collapse

Class Method Details

.<=>(other) ⇒ Object



44
45
46
# File 'lib/howl/plugin.rb', line 44

def self.<=>(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.

base - The Class subclass.

Returns nothing.



17
18
19
20
# File 'lib/howl/plugin.rb', line 17

def self.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.

priority - The Symbol priority (default: nil). Valid options are:

:lowest, :low, :normal, :high, :highest

Returns the Symbol priority.



37
38
39
40
41
42
# File 'lib/howl/plugin.rb', line 37

def self.priority(priority = nil)
  if priority && PRIORITIES.has_key?(priority)
    @priority = priority
  end
  @priority || :normal
end

.subclassesObject

The list of Classes that have been subclassed.

Returns an Array of Class objects.



25
26
27
# File 'lib/howl/plugin.rb', line 25

def self.subclasses
  @subclasses ||= []
end