Class: Leftovers::Processors::Split
- Inherits:
-
Object
- Object
- Leftovers::Processors::Split
- Includes:
- ComparableInstance
- Defined in:
- lib/leftovers/processors/split.rb
Instance Method Summary collapse
-
#initialize(split_on, then_processor) ⇒ Split
constructor
A new instance of Split.
- #process(str, current_node, matched_node, acc) ⇒ Object
Methods included from ComparableInstance
Constructor Details
#initialize(split_on, then_processor) ⇒ Split
Returns a new instance of Split.
8 9 10 11 12 13 |
# File 'lib/leftovers/processors/split.rb', line 8 def initialize(split_on, then_processor) @split_on = split_on @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/split.rb', line 15 def process(str, current_node, matched_node, acc) return unless str str.split(@split_on).each do |sub_str| @then_processor.process(sub_str, current_node, matched_node, acc) end end |