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