class Wongi::Engine::BetaNode

Attributes

children[RW]
parent[R]
rete[W]

Public Class Methods

new(parent = nil) click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 33
def initialize parent = nil
  @parent = parent
  @children = []
  if parent
    parent.children << self
  end
end

Public Instance Methods

assignment_node(variable, body) click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 66
def assignment_node variable, body
  node = AssignmentNode.new self, variable, body
  node.refresh
  node
end
depth() click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 45
def depth
  @depth ||= if parent.nil?
    0
  else
    parent.depth + 1
  end
end
refresh() click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 72
def refresh
  parent.refresh_child self
end
refresh_child(node) click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 76
def refresh_child node
  raise "#{self.class} must implement refresh_child"
end
rete() click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 53
def rete
  @rete ||= if parent
    parent.rete
  end
end
root?() click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 41
def root?
  parent.nil?
end

Private Instance Methods

dp(message) click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 82
def dp message
  if debug?
    puts "#{indent}#{message}"
  end
end
indent() click to toggle source
# File lib/wongi-engine/beta/beta_node.rb, line 88
def indent
  '  ' * depth
end