Class: JRuby::Lint::AST::Visitor
- Inherits:
-
Object
- Object
- JRuby::Lint::AST::Visitor
show all
- Includes:
- Enumerable
- Defined in:
- lib/jruby/lint/ast.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ast) ⇒ Visitor
37
38
39
|
# File 'lib/jruby/lint/ast.rb', line 37
def initialize(ast)
@ast = ast
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/jruby/lint/ast.rb', line 58
def method_missing(name, *args, &block)
if name.to_s =~ /^visit/
visit(name, *args)
else
super
end
end
|
Instance Attribute Details
#ast ⇒ Object
Returns the value of attribute ast.
35
36
37
|
# File 'lib/jruby/lint/ast.rb', line 35
def ast
@ast
end
|
Instance Method Details
#each(&block) ⇒ Object
Also known as:
each_node, traverse
41
42
43
44
45
46
|
# File 'lib/jruby/lint/ast.rb', line 41
def each(&block)
@block = block
ast.accept(self)
ensure
@block = nil
end
|
#visit(method, node) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/jruby/lint/ast.rb', line 51
def visit(method, node)
@block.call(node) if @block
node.child_nodes.each do |cn|
cn.accept(self) rescue nil
end
end
|