class Leftovers::ValueProcessors::KeywordArgument

Public Class Methods

new(matcher, then_processor) click to toggle source

:nocov:

# File lib/leftovers/value_processors/keyword_argument.rb, line 10
def initialize(matcher, then_processor)
  @matcher = matcher
  @then_processor = then_processor

  freeze
end

Public Instance Methods

process(_str, node, method_node) click to toggle source
# File lib/leftovers/value_processors/keyword_argument.rb, line 17
def process(_str, node, method_node)
  kwargs = node.kwargs
  return unless kwargs

  result = []

  kwargs.children.each do |pair|
    next unless @matcher === pair

    argument_node = pair.second
    str = argument_node.to_s if argument_node.string_or_symbol?

    result << @then_processor.process(str, argument_node, method_node)
  end

  result
end