123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::AST::NodePattern::Node::Subsequence

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RuboCop::AST::NodePattern::Node
Defined in: lib/rubocop/ast/node_pattern/node.rb

Overview

A list (potentially empty) of nodes; part of a Union

Constant Summary

::RuboCop::AST::NodePattern::Node - Inherited

FunctionCall, INT_TO_RANGE, MAP, MATCHES_WITHIN_SET

Class Method Summary

Instance Attribute Summary

::RuboCop::AST::NodePattern::Node - Inherited

#capture?,
#matches_within_set?

that matches within a Set (e.g.

#rest?

To be overridden by subclasses.

#variadic?

Instance Method Summary

ForbidInSeqHead - Included

::RuboCop::AST::NodePattern::Node - Inherited

::RuboCop::AST::Descendence - Included

#child_nodes

Returns an array of child nodes.

#descendants

Returns an array of descendant nodes.

#each_child_node

Calls the given block for each child node.

#each_descendant

Calls the given block for each descendant node with depth first order.

#each_node

Calls the given block for the receiver and each descendant node in depth-first order.

Instance Method Details

#arity

[ GitHub ]

  
# File 'lib/rubocop/ast/node_pattern/node.rb', line 208

def arity
  min, max = children.map { |child| child.arity_range.minmax }.transpose.map(&:sum)
  min == max ? min || 0 : min..max # NOTE: || 0 for empty case, where min == max == nil.
end

#in_sequence_head

[ GitHub ]

  
# File 'lib/rubocop/ast/node_pattern/node.rb', line 213

def in_sequence_head
  super if children.empty?

  return unless (replace = children.first.in_sequence_head)

  [with(children: [*replace, *children[1..]])]
end