Method: RuboCop::Ext::RegexpNode#each_capture

Defined in:
lib/rubocop/ext/regexp_node.rb

#each_capture(named: ANY) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/rubocop/ext/regexp_node.rb', line 31

def each_capture(named: ANY)
  return enum_for(__method__, named: named) unless block_given?

  parsed_tree&.traverse do |event, exp, _index|
    yield(exp) if named_capturing?(exp, event, named)
  end

  self
end