Class: RuboCop::AST::NodePattern::Node::Union
- Inherits:
-
RuboCop::AST::NodePattern::Node
- Object
- Parser::AST::Node
- RuboCop::AST::NodePattern::Node
- RuboCop::AST::NodePattern::Node::Union
- Defined in:
- lib/rubocop/ast/node_pattern/node.rb
Overview
Node class for ‘{ … }`
Constant Summary
Constants inherited from RuboCop::AST::NodePattern::Node
Instance Method Summary collapse
Methods inherited from RuboCop::AST::NodePattern::Node
#arity_range, #capture?, #child, #children_nodes, #matches_within_set?, #nb_captures, #rest?, #source_range, #variadic?, #with
Methods included from SimpleForwardable
Methods included from Descendence
#child_nodes, #descendants, #each_child_node, #each_descendant, #each_node
Instance Method Details
#arity ⇒ Object
224 225 226 227 228 229 |
# File 'lib/rubocop/ast/node_pattern/node.rb', line 224 def arity minima, maxima = children.map { |child| child.arity_range.minmax }.transpose min = minima.min max = maxima.max min == max ? min : min..max end |
#in_sequence_head ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/rubocop/ast/node_pattern/node.rb', line 231 def in_sequence_head return unless children.any?(&:in_sequence_head) new_children = children.map do |child| next child unless (replace = child.in_sequence_head) if replace.size > 1 Subsequence.new(:subsequence, replace, loc: child.loc) else replace.first end end [with(children: new_children)] end |