Class: Bookbinder::Preprocessing::Preprocessor

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/preprocessing/preprocessor.rb

Defined Under Namespace

Classes: NullProcess

Instance Method Summary collapse

Constructor Details

#initialize(*processes) ⇒ Preprocessor

Returns a new instance of Preprocessor.



9
10
11
# File 'lib/bookbinder/preprocessing/preprocessor.rb', line 9

def initialize(*processes)
  @processes = processes
end

Instance Method Details

#preprocess(sections, *args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/bookbinder/preprocessing/preprocessor.rb', line 13

def preprocess(sections, *args)
  sections.group_by { |section|
    processes.detect(Proc.new { NullProcess.new }) { |process| process.applicable_to?(section) }
  }.each do |process, grouped_sections|
    process.preprocess(grouped_sections, *args)
  end
end