class RDG::Tree::AST::Node

Attributes

wrapped[RW]

Public Class Methods

new(wrapped, graph) click to toggle source
# File lib/rdg/tree/ast.rb, line 55
def initialize(wrapped, graph)
  @wrapped = wrapped
  @graph = graph
end

Public Instance Methods

==(other) click to toggle source
# File lib/rdg/tree/ast.rb, line 92
def ==(other)
  if scalar?
    wrapped == other.wrapped
  else
    type == other.type && children == other.children
  end
end
ancestors() click to toggle source
# File lib/rdg/tree/ast.rb, line 84
def ancestors
  parent.nil? ? [] : parent.ancestors.unshift(parent)
end
children() click to toggle source
# File lib/rdg/tree/ast.rb, line 76
def children
  @graph.each_successor(self).to_a
end
compound?() click to toggle source
# File lib/rdg/tree/ast.rb, line 60
def compound?
  wrapped.is_a?(Parser::AST::Node)
end
empty?() click to toggle source
# File lib/rdg/tree/ast.rb, line 68
def empty?
  wrapped.nil?
end
inspect() click to toggle source
# File lib/rdg/tree/ast.rb, line 100
def inspect
  to_s
end
parent() click to toggle source
# File lib/rdg/tree/ast.rb, line 80
def parent
  @graph.each_predecessor(self).first
end
scalar?() click to toggle source
# File lib/rdg/tree/ast.rb, line 64
def scalar?
  !compound?
end
siblings() click to toggle source
# File lib/rdg/tree/ast.rb, line 88
def siblings
  parent.nil? ? [] : parent.children
end
to_s() click to toggle source
# File lib/rdg/tree/ast.rb, line 104
def to_s
  wrapped.to_s
end
type() click to toggle source
# File lib/rdg/tree/ast.rb, line 72
def type
  compound? ? wrapped.type : nil
end