Class: Leftovers::Processors::EachKeyword

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

Instance Method Summary collapse

Methods included from ComparableInstance

#eql?, #hash

Constructor Details

#initialize(then_processor) ⇒ EachKeyword

Returns a new instance of EachKeyword.



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

def initialize(then_processor)
  @then_processor = then_processor

  freeze
end

Instance Method Details

#process(_str, current_node, matched_node, acc) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/leftovers/processors/each_keyword.rb', line 14

def process(_str, current_node, matched_node, acc)
  kwargs = current_node.kwargs
  return unless kwargs

  kwargs.children.each do |pair|
    next unless pair.type == :pair

    key_node = pair.first
    @then_processor.process(key_node.to_literal_s, key_node, matched_node, acc)
  end
end