Class: Leftovers::Processors::Split

Inherits:
Object
  • Object
show all
Includes:
ComparableInstance
Defined in:
lib/leftovers/processors/split.rb

Instance Method Summary collapse

Methods included from ComparableInstance

#eql?, #hash

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