Class: Leftovers::Processors::EachPositionalArgumentFrom

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

Instance Method Summary collapse

Methods included from ComparableInstance

#eql?, #hash

Constructor Details

#initialize(position, then_processor) ⇒ EachPositionalArgumentFrom

Returns a new instance of EachPositionalArgumentFrom.



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

def initialize(position, then_processor)
  @position = position
  @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
25
# File 'lib/leftovers/processors/each_positional_argument_from.rb', line 15

def process(_str, current_node, matched_node, acc)
  positional_arguments = current_node.positional_arguments

  return unless positional_arguments

  positional_arguments.each_with_index do |argument_node, index|
    next if index < @position

    @then_processor.process(argument_node.to_literal_s, argument_node, matched_node, acc)
  end
end