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 SimpleForwardable

#def_delegators

Methods included from Descendence

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

Instance Method Details

#capture?Boolean

Returns:

  • (Boolean)


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

def capture?
  true
end

#in_sequence_headObject



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

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

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

#nb_capturesObject



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

def nb_captures
  1 + super
end