Class: Unparser::AST::Enumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Unparser::Adamantium
Defined in:
lib/unparser/ast.rb

Overview

AST enumerator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(node, controller = TAUTOLOGY) ⇒ Enumerator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return new instance

Parameters:

  • node (Parser::AST::Node)
  • controller (#call(node)) (defaults to: TAUTOLOGY)

Returns:



92
93
94
# File 'lib/unparser/ast.rb', line 92

def self.new(node, controller = TAUTOLOGY)
  super
end

Instance Method Details

#each(&block) ⇒ Enumerator<Parser::AST::Node>, self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return each node

Returns:

  • (Enumerator<Parser::AST::Node>)

    if no block given

  • (self)

    otherwise



106
107
108
# File 'lib/unparser/ast.rb', line 106

def each(&block)
  Walker.call(node, controller, &block)
end

#type(type) ⇒ Enumerable<Parser::AST::Node>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return nodes selected by type

Parameters:

  • type (Symbol)

Returns:

  • (Enumerable<Parser::AST::Node>)


130
131
132
# File 'lib/unparser/ast.rb', line 130

def type(type)
  select { |node| node.type.equal?(type) }
end

#types(types) ⇒ Enumerable<Parser::AST::Node>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return nodes selected by types

Parameters:

  • types (Enumerable<Symbol>)

Returns:

  • (Enumerable<Parser::AST::Node>)


118
119
120
# File 'lib/unparser/ast.rb', line 118

def types(types)
  select { |node| types.include?(node.type) }
end