module RuboCop::AST::Descendence
def child_nodes
-
(Array
- an array of child nodes)
def child_nodes each_child_node.to_a end
def descendants
-
(Array
- an array of descendant nodes)
def descendants each_descendant.to_a end
def each_child_node(*types)
-
(Enumerator)
- if no block is given -
(self)
- if a block is given
Other tags:
- Yieldparam: node - each child node
Parameters:
-
type
(Symbol
) -- a node type
Overloads:
-
each_child_node(type, ...)
-
each_child_node
def each_child_node(*types) return to_enum(__method__, *types) unless block_given? children.each do |child| next unless child.is_a?(::AST::Node) yield child if types.empty? || types.include?(child.type) end self end
def each_descendant(*types, &block)
-
(Enumerator)
- if no block is given -
(self)
- if a block is given
Other tags:
- Yieldparam: node - each descendant node
Parameters:
-
type_b
(Symbol
) -- a node type -
type_a
(Symbol
) -- a node type -
type
(Symbol
) -- a node type
Overloads:
-
each_descendant(type_a, type_b, ...)
-
each_descendant(type)
-
each_descendant
def each_descendant(*types, &block) return to_enum(__method__, *types) unless block visit_descendants(types, &block) self end
def each_node(*types, &block)
-
(Enumerator)
- if no block is given -
(self)
- if a block is given
Other tags:
- Yieldparam: node - each node
Parameters:
-
type_b
(Symbol
) -- a node type -
type_a
(Symbol
) -- a node type -
type
(Symbol
) -- a node type
Overloads:
-
each_node(type_a, type_b, ...)
-
each_node(type)
-
each_node
def each_node(*types, &block) return to_enum(__method__, *types) unless block yield self if types.empty? || types.include?(type) visit_descendants(types, &block) self end
def visit_descendants(types, &block)
def visit_descendants(types, &block) each_child_node do |child| yield child if types.empty? || types.include?(child.type) child.visit_descendants(types, &block) end end