Class: Bookbinder::Preprocessing::Preprocessor
- Inherits:
-
Object
- Object
- Bookbinder::Preprocessing::Preprocessor
- Defined in:
- lib/bookbinder/preprocessing/preprocessor.rb
Defined Under Namespace
Classes: NullProcess
Instance Method Summary collapse
-
#initialize(*processes) ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #preprocess(sections, *args) ⇒ Object
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 |