class Wongi::Engine::AssignmentNode

Attributes

body[R]
variable[R]

Public Class Methods

new(parent, variable, body) click to toggle source
Calls superclass method
# File lib/wongi-engine/beta/assignment_node.rb, line 5
def initialize(parent, variable, body)
  super(parent)
  @variable = variable
  @body = body
end

Public Instance Methods

beta_activate(token, _wme = nil, _assignments = {}) click to toggle source
# File lib/wongi-engine/beta/assignment_node.rb, line 11
def beta_activate(token, _wme = nil, _assignments = {})
  return if tokens.find { |t| t.duplicate? token }

  overlay.add_token(token)
  children.each do |child|
    value = body.respond_to?(:call) ? body.call(token) : body
    child.beta_activate Token.new(child, token, nil, { variable => value })
  end
end
beta_deactivate(token) click to toggle source
# File lib/wongi-engine/beta/assignment_node.rb, line 21
def beta_deactivate(token)
  overlay.remove_token(token)
  children.each do |child|
    child.tokens.each do |t|
      if t.child_of?(token)
        child.beta_deactivate t
        # token.destroy
      end
    end
  end
end
refresh_child(child) click to toggle source
# File lib/wongi-engine/beta/assignment_node.rb, line 33
def refresh_child(child)
  tokens.each do |token|
    child.beta_activate Token.new(child, token, nil, { variable => body.respond_to?(:call) ? body.call(token) : body })
  end
end