Class: Wongi::Engine::NccNode
- Defined in:
- lib/wongi-engine/beta/ncc_node.rb
Instance Attribute Summary collapse
-
#partner ⇒ Object
Returns the value of attribute partner.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Attributes inherited from BetaNode
Instance Method Summary collapse
-
#beta_activate(token, wme = nil, assignments = { }) ⇒ Object
def beta_activate token, wme, assignments t = Token.new token, wme, assignments t.node = self.
- #delete_token(token) ⇒ Object
-
#initialize(parent) ⇒ NccNode
constructor
A new instance of NccNode.
- #refresh_child(child) ⇒ Object
Methods inherited from BetaNode
#assignment_node, #beta_memory, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #refresh
Methods included from CoreExt
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
#partner ⇒ Object
Returns the value of attribute partner.
21 22 23 |
# File 'lib/wongi-engine/beta/ncc_node.rb', line 21 def partner @partner end |
#tokens ⇒ Object (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
#beta_activate(token, wme = nil, assignments = { }) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wongi-engine/beta/ncc_node.rb', line 31 def beta_activate token, wme = nil, assignments = { } # => FIXME: beta_activate has different signatures for storing and non-storing nodes... t = Token.new token, nil, {} t.node = self tokens << t partner.tokens.each do |ncc_token| next unless ncc_token.ancestors.find { |a| a.equal? token } t.ncc_results << ncc_token ncc_token.owner = t end if t.ncc_results.empty? children.each do |child| child.beta_activate t, nil, {} end end end |
#delete_token(token) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/wongi-engine/beta/ncc_node.rb', line 55 def delete_token token tokens.delete token token.ncc_results.each do |nccr| nccr.wme.tokens.delete nccr nccr.parent.children.delete nccr end token.ncc_results.clear end |
#refresh_child(child) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/wongi-engine/beta/ncc_node.rb', line 47 def refresh_child child tokens.each do |token| if token.ncc_results.empty? child.beta_activate token, nil, {} end end end |