class Unparser::AST::Enumerator

AST enumerator

Public Class Methods

new(node, controller = TAUTOLOGY) click to toggle source

Return new instance

@param [Parser::AST::Node] node @param [#call(node)] controller

@return [Enumerator]

@api private

Calls superclass method
# File lib/unparser/ast.rb, line 92
def self.new(node, controller = TAUTOLOGY)
  super
end

Private Class Methods

set(enumerable) click to toggle source

Return frozne set of objects

@param [Enumerable] enumerable

@return [Set]

@api private

# File lib/unparser/ast.rb, line 142
def self.set(enumerable)
  enumerable.to_set.freeze
end
type(node, type) click to toggle source

Return nodes of type

@param [Parser::AST::Node] node @param [Symbol] type

@return [Enumerable<Parser::AST::Node]

@api private

# File lib/unparser/ast.rb, line 156
def self.type(node, type)
  new(node).type(type)
end

Public Instance Methods

each(&block) click to toggle source

Return each node

@return [Enumerator<Parser::AST::Node>]

if no block given

@return [self]

otherwise

@api private

# File lib/unparser/ast.rb, line 106
def each(&block)
  Walker.call(node, controller, &block)
end
type(type) click to toggle source

Return nodes selected by type

@param [Symbol] type

@return [Enumerable<Parser::AST::Node>]

@api private

# File lib/unparser/ast.rb, line 130
def type(type)
  select { |node| node.type.equal?(type) }
end
types(types) click to toggle source

Return nodes selected by types

@param [Enumerable<Symbol>] types

@return [Enumerable<Parser::AST::Node>]

@api private

# File lib/unparser/ast.rb, line 118
def types(types)
  select { |node| types.include?(node.type) }
end