Class: Wongi::Engine::AssignmentNode

Inherits:
BetaNode
  • Object
show all
Defined in:
lib/wongi-engine/beta/assignment_node.rb

Instance Attribute Summary

Attributes inherited from BetaNode

#children, #parent, #rete

Instance Method Summary collapse

Methods inherited from BetaNode

#assignment_node, #beta_memory, #delete_token, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #refresh

Methods included from CoreExt

included

Constructor Details

#initialize(parent, variable, body) ⇒ AssignmentNode

Returns a new instance of AssignmentNode.



19
20
21
22
# File 'lib/wongi-engine/beta/assignment_node.rb', line 19

def initialize parent, variable, body
  super parent
  @variable, @body = variable, body
end

Instance Method Details

#beta_activate(token, wme = nil, assignments = { }) ⇒ Object



24
25
26
# File 'lib/wongi-engine/beta/assignment_node.rb', line 24

def beta_activate token, wme = nil, assignments = { }
  propagate_activation token, nil, { @variable => @body.call(token) }
end

#refresh_child(child) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/wongi-engine/beta/assignment_node.rb', line 28

def refresh_child child
  tmp = children
  self.children = [ child ]
  parent.tokens.each do |token|
    beta_activate token
  end
  self.children = tmp
end