Class: Wongi::Engine::FilterNode
- Defined in:
- lib/wongi-engine/beta/filter_node.rb
Instance Attribute Summary collapse
-
#test ⇒ Object
Returns the value of attribute test.
Attributes inherited from BetaNode
#children, #context, #parent, #rete
Instance Method Summary collapse
- #beta_activate(token) ⇒ Object
- #beta_deactivate(token) ⇒ Object
- #equivalent?(test) ⇒ Boolean
-
#initialize(parent, test) ⇒ FilterNode
constructor
A new instance of FilterNode.
- #refresh_child(child) ⇒ Object
Methods inherited from BetaNode
#assignment_node, #beta_memory, #delete_token, #depth, #empty?, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #refresh, #size, #tokens
Methods included from CoreExt
Constructor Details
#initialize(parent, test) ⇒ FilterNode
Returns a new instance of FilterNode.
8 9 10 11 |
# File 'lib/wongi-engine/beta/filter_node.rb', line 8 def initialize parent, test super parent self.test = test end |
Instance Attribute Details
#test ⇒ Object
Returns the value of attribute test.
6 7 8 |
# File 'lib/wongi-engine/beta/filter_node.rb', line 6 def test @test end |
Instance Method Details
#beta_activate(token) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/wongi-engine/beta/filter_node.rb', line 13 def beta_activate token if test.passes? token children.each do |child| child.beta_activate Token.new( child, token, nil, {} ) end end end |
#beta_deactivate(token) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wongi-engine/beta/filter_node.rb', line 21 def beta_deactivate token children.each do |child| child.tokens.each do |t| if t.parent == token child.beta_deactivate t #token.destroy end end end end |
#equivalent?(test) ⇒ Boolean
32 33 34 |
# File 'lib/wongi-engine/beta/filter_node.rb', line 32 def equivalent? test test == self.test end |
#refresh_child(child) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/wongi-engine/beta/filter_node.rb', line 36 def refresh_child child tmp = children self.children = [ child ] parent.tokens.each do |token| beta_activate token end self.children = tmp end |