Class: Wongi::Engine::NccNode
Instance Attribute Summary collapse
Attributes inherited from BetaNode
#children, #parent, #rete
Instance Method Summary
collapse
Methods inherited from BetaNode
#assignment_node, #beta_deactivate_children, #depth, #empty?, #initialize, #overlay, #refresh, #root?, #size, #tokens
Methods included from CoreExt
included
Instance Attribute Details
#partner ⇒ Object
Returns the value of attribute partner.
4
5
6
|
# File 'lib/wongi-engine/beta/ncc_node.rb', line 4
def partner
@partner
end
|
Instance Method Details
#beta_activate(token) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/wongi-engine/beta/ncc_node.rb', line 6
def beta_activate(token)
return if tokens.find { |t| t.duplicate? token }
overlay.add_token(token)
partner.tokens.each do |ncc_token|
if partner.owner_for(ncc_token) == token
overlay.add_ncc_token(token, ncc_token)
end
end
return if overlay.ncc_tokens_for(token).any?
children.each do |child|
child.beta_activate Token.new(child, token, nil, {})
end
end
|
#beta_deactivate(token) ⇒ Object
23
24
25
26
27
|
# File 'lib/wongi-engine/beta/ncc_node.rb', line 23
def beta_deactivate(token)
overlay.remove_token(token)
beta_deactivate_children(token: token)
end
|
#ncc_activate(token) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/wongi-engine/beta/ncc_node.rb', line 29
def ncc_activate(token)
children.each do |child|
child.beta_activate Token.new(child, token, nil, {})
end
end
|
#ncc_deactivate(token) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/wongi-engine/beta/ncc_node.rb', line 36
def ncc_deactivate(token)
children.each do |beta|
beta.tokens.select { |t| t.child_of?(token) }.each do |t|
beta.beta_deactivate t
end
end
end
|
#refresh_child(child) ⇒ Object
45
46
47
48
49
|
# File 'lib/wongi-engine/beta/ncc_node.rb', line 45
def refresh_child(child)
tokens.each do |token|
child.beta_activate Token.new(child, token, nil, {}) if overlay.ncc_tokens_for(token).empty?
end
end
|