Class: Leftovers::Processors::AddDynamicPrefix
- Inherits:
-
Object
- Object
- Leftovers::Processors::AddDynamicPrefix
- Includes:
- ComparableInstance
- Defined in:
- lib/leftovers/processors/add_dynamic_prefix.rb
Instance Method Summary collapse
-
#initialize(prefix_processor, then_processor) ⇒ AddDynamicPrefix
constructor
A new instance of AddDynamicPrefix.
- #process(str, current_node, matched_node, acc) ⇒ Object
Methods included from ComparableInstance
Constructor Details
#initialize(prefix_processor, then_processor) ⇒ AddDynamicPrefix
Returns a new instance of AddDynamicPrefix.
8 9 10 11 12 13 |
# File 'lib/leftovers/processors/add_dynamic_prefix.rb', line 8 def initialize(prefix_processor, then_processor) @prefix_processor = prefix_processor @then_processor = then_processor freeze end |
Instance Method Details
#process(str, current_node, matched_node, acc) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/leftovers/processors/add_dynamic_prefix.rb', line 15 def process(str, current_node, matched_node, acc) return unless str prefixes = [] @prefix_processor.process(nil, matched_node, matched_node, prefixes) prefixes.each do |prefix| @then_processor.process("#{prefix}#{str}", current_node, matched_node, acc) end end |