Class: Leftovers::Processors::AddDynamicSuffix

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

Instance Method Summary collapse

Methods included from ComparableInstance

#eql?, #hash

Constructor Details

#initialize(suffix_processor, then_processor) ⇒ AddDynamicSuffix

Returns a new instance of AddDynamicSuffix.



8
9
10
11
12
13
# File 'lib/leftovers/processors/add_dynamic_suffix.rb', line 8

def initialize(suffix_processor, then_processor)
  @suffix_processor = suffix_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_suffix.rb', line 15

def process(str, current_node, matched_node, acc)
  return unless str

  suffixes = []
  @suffix_processor.process(nil, matched_node, matched_node, suffixes)

  suffixes.each do |suffix|
    @then_processor.process("#{str}#{suffix}", current_node, matched_node, acc)
  end
end