Class: Leftovers::Processors::DeleteBefore
- Inherits:
-
Object
- Object
- Leftovers::Processors::DeleteBefore
- Includes:
- ComparableInstance
- Defined in:
- lib/leftovers/processors/delete_before.rb
Instance Method Summary collapse
-
#initialize(delete_before, then_processor) ⇒ DeleteBefore
constructor
A new instance of DeleteBefore.
- #process(str, current_node, matched_node, acc) ⇒ Object
Methods included from ComparableInstance
Constructor Details
#initialize(delete_before, then_processor) ⇒ DeleteBefore
Returns a new instance of DeleteBefore.
8 9 10 11 12 13 14 |
# File 'lib/leftovers/processors/delete_before.rb', line 8 def initialize(delete_before, then_processor) @delete_before = delete_before @delete_before_length = delete_before.length @then_processor = then_processor freeze end |
Instance Method Details
#process(str, current_node, matched_node, acc) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/leftovers/processors/delete_before.rb', line 16 def process(str, current_node, matched_node, acc) return unless str index = str.index(@delete_before) str = str[(index + @delete_before_length)..-1] if index @then_processor.process(str, current_node, matched_node, acc) end |