Class: Wongi::Engine::NccNode

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

Instance Attribute Summary collapse

Attributes inherited from BetaNode

#children, #parent, #rete

Instance Method Summary collapse

Methods inherited from BetaNode

#beta_memory, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #update_above

Methods included from CoreExt

included

Constructor Details

#initialize(parent) ⇒ NccNode

Returns a new instance of NccNode.



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

def initialize parent
  super
  @tokens = []
end

Instance Attribute Details

#partnerObject

Returns the value of attribute partner.



21
22
23
# File 'lib/wongi-engine/beta/ncc_node.rb', line 21

def partner
  @partner
end

#tokensObject (readonly)

Returns the value of attribute tokens.



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

def tokens
  @tokens
end

Instance Method Details

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

def left_activate token, wme, assignments

t = Token.new token, wme, assignments
t.node = self


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/wongi-engine/beta/ncc_node.rb', line 31

def left_activate token, wme = nil, assignments = { } # => FIXME: left_activate has different signatures for storing and non-storing nodes...
  t = Token.new token, nil, {}
  tokens << t
  partner.tokens.each do |ncc_token|
    t.ncc_results << ncc_token
    ncc_token.owner = t
  end
  if t.ncc_results.empty?
    children.each do |child|
      child.left_activate t, nil, {}
    end
  end
end