Class: RuboCop::AST::NodePattern::Node::AnyOrder

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

Overview

Node class for ‘<int str …>`

Constant Summary

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

FunctionCall, MAP

Instance Method Summary collapse

Methods included from ForbidInSeqHead

#in_sequence_head

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

#arity_range, #capture?, #child, #children_nodes, #in_sequence_head, #matches_within_set?, #nb_captures, #rest?, #source_range, #variadic?, #with

Methods included from Descendence

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

Instance Method Details

#arityObject



198
199
200
201
202
# File 'lib/rubocop/ast/node_pattern/node.rb', line 198

def arity
  return children.size unless ends_with_rest?

  ARITIES[children.size]
end

#ends_with_rest?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'lib/rubocop/ast/node_pattern/node.rb', line 190

def ends_with_rest?
  children.last.rest?
end

#rest_nodeObject



194
195
196
# File 'lib/rubocop/ast/node_pattern/node.rb', line 194

def rest_node
  children.last if ends_with_rest?
end

#term_nodesObject



186
187
188
# File 'lib/rubocop/ast/node_pattern/node.rb', line 186

def term_nodes
  ends_with_rest? ? children[0...-1] : children
end