Class: RuboCop::AST::NodePattern::Node::Capture

Inherits:
RuboCop::AST::NodePattern::Node show all
Defined in:
lib/rubocop/ast/node_pattern/node.rb

Overview

Node class for ‘$something`

Constant Summary

Constants inherited from RuboCop::AST::NodePattern::Node

FunctionCall, MAP

Instance Method Summary collapse

Methods inherited from RuboCop::AST::NodePattern::Node

#arity, #arity_range, #child, #children_nodes, #matches_within_set?, #rest?, #source_range, #variadic?, #with

Methods included from Descendence

#child_nodes, #descendants, #each_child_node, #each_descendant, #each_node

Instance Method Details

#capture?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/rubocop/ast/node_pattern/node.rb', line 101

def capture?
  true
end

#in_sequence_headObject



109
110
111
112
113
114
# File 'lib/rubocop/ast/node_pattern/node.rb', line 109

def in_sequence_head
  wildcard, original_child = child.in_sequence_head
  return unless original_child

  [wildcard, self] # ($...) => (_ $...)
end

#nb_capturesObject



105
106
107
# File 'lib/rubocop/ast/node_pattern/node.rb', line 105

def nb_captures
  1 + super
end