Class: Wongi::Engine::NccPartner

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

Instance Attribute Summary collapse

Attributes inherited from BetaNode

#children, #parent, #rete

Instance Method Summary collapse

Methods inherited from BetaNode

#assignment_node, #depth, #initialize, #refresh, #refresh_child, #root?

Methods included from CoreExt

included

Constructor Details

This class inherits a constructor from Wongi::Engine::BetaNode

Instance Attribute Details

#divergentObject

Returns the value of attribute divergent.



7
8
9
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 7

def divergent
  @divergent
end

#nccObject

Returns the value of attribute ncc.



6
7
8
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 6

def ncc
  @ncc
end

Instance Method Details

#beta_activate(token) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 9

def beta_activate token
  t = Token.new self, token, nil, {}
  owner = owner_for( t )
  t.overlay.add_token(t, self)
  if owner
    owner.ncc_results << t
    t.owner = owner
    owner.node.ncc_deactivate owner
  end
end

#beta_deactivate(t) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 20

def beta_deactivate t
  token = tokens.find { |tok| tok.parent == t }
  return unless token
  token.overlay.remove_token(token, self)
  if owner = token.owner
    owner.ncc_results.delete token
    if owner.ncc_results.empty?
      ncc.ncc_activate owner
    end
  end
end