Class: CabbageDoc::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/cabbage_doc/processor.rb

Direct Known Subclasses

CabbageDoc::Processors::Documentation

Defined Under Namespace

Classes: Error, InvalidPriority, InvalidType

Constant Summary collapse

PRIORITIES =
[:high, :medium, :low].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



23
24
25
# File 'lib/cabbage_doc/processor.rb', line 23

def all
  @_all ||= {}
end

.inherited(klass) ⇒ Object



10
11
12
# File 'lib/cabbage_doc/processor.rb', line 10

def inherited(klass)
  all[klass.to_s.split('::').last.downcase.to_sym] = klass
end

.load!Object



37
38
39
40
41
# File 'lib/cabbage_doc/processor.rb', line 37

def load!
  Dir.glob(File.join(File.dirname(__FILE__), 'processors', '*.rb')).sort.each do |processor|
    require(processor)
  end
end

.perform(type) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/cabbage_doc/processor.rb', line 27

def perform(type)
  klass = all[type]

  if klass
    klass.new.perform
  else
    raise InvalidType, type
  end
end

.priority(value = nil) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/cabbage_doc/processor.rb', line 14

def priority(value = nil)
  if value.is_a?(Symbol)
    raise InvalidPriority, value unless PRIORITIES.include?(value)
    @_priority = value
  else
    @_priority
  end
end

Instance Method Details

#performObject

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/cabbage_doc/processor.rb', line 44

def perform
  raise NotImplementedError
end