class RKelly::Nodes::Node
Attributes
comments[RW]
filename[RW]
line[RW]
value[RW]
Public Class Methods
new(value)
click to toggle source
# File lib/rkelly/nodes/node.rb, line 9 def initialize(value) @value = value @comments = [] @filename = @line = nil end
Public Instance Methods
==(other)
click to toggle source
# File lib/rkelly/nodes/node.rb, line 15 def ==(other) other.is_a?(self.class) && @value == other.value end
Also aliased as: =~
===(other)
click to toggle source
# File lib/rkelly/nodes/node.rb, line 20 def ===(other) other.is_a?(self.class) && @value === other.value end
each(&block)
click to toggle source
# File lib/rkelly/nodes/node.rb, line 71 def each(&block) EnumerableVisitor.new(block).accept(self) end
pointcut(pattern)
click to toggle source
# File lib/rkelly/nodes/node.rb, line 24 def pointcut(pattern) case pattern when String ast = RKelly::Parser.new.parse(pattern) # Only take the first statement finder = ast.value.first.class.to_s =~ /StatementNode$/ ? ast.value.first.value : ast.value.first visitor = PointcutVisitor.new(finder) else visitor = PointcutVisitor.new(pattern) end visitor.accept(self) visitor end
Also aliased as: /
to_dots()
click to toggle source
# File lib/rkelly/nodes/node.rb, line 49 def to_dots visitor = DotVisitor.new visitor.accept(self) header = <<-END digraph g { graph [ rankdir = "TB" ]; node [ fontsize = "16" shape = "ellipse" ]; edge [ ]; END nodes = visitor.nodes.map { |x| x.to_s }.join("\n") counter = 0 arrows = visitor.arrows.map { |x| s = "#{x} [\nid = #{counter}\n];" counter += 1 s }.join("\n") "#{header}\n#{nodes}\n#{arrows}\n}" end
to_ecma()
click to toggle source
# File lib/rkelly/nodes/node.rb, line 45 def to_ecma ECMAVisitor.new.accept(self) end
to_real_sexp()
click to toggle source
# File lib/rkelly/nodes/node.rb, line 75 def to_real_sexp RealSexpVisitor.new.accept(self) end
to_sexp()
click to toggle source
# File lib/rkelly/nodes/node.rb, line 41 def to_sexp SexpVisitor.new.accept(self) end