Class: Ruleby::Core::NotNode
Overview
This node class is used when a rule is looking for a fact that does not exist. It is a two-input node, and thus has some of the properties of the JoinNode. NOTE it has not clear how this will work if the NotPattern is declared as the first pattern in a rule.
Instance Attribute Summary
Attributes inherited from JoinNode
#ref_nodes
Attributes inherited from ParentNode
#child_nodes
Attributes inherited from Printable
#parent_nodes
Instance Method Summary
collapse
Methods inherited from JoinNode
#retract_resolve, #to_s
Methods inherited from ParentNode
#add_out_node, #assert, #forks?, #propagate_assert, #propagate_retract, #retract
Methods inherited from Node
#resolve
Methods inherited from Printable
#print
Constructor Details
Returns a new instance of NotNode.
651
652
653
|
# File 'lib/core/nodes.rb', line 651
def initialize
super
end
|
Instance Method Details
#assert_left(context) ⇒ Object
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
|
# File 'lib/core/nodes.rb', line 679
def assert_left(context)
add_to_left_memory(context)
if @ref_nodes.empty? && @right_memory.empty?
propagate_assert(context)
else
propagate = true
@right_memory.values.each do |right_context|
if match_ref_nodes(context,right_context)
propagate = false
break
end
end
propagate_assert(context) if propagate
end
end
|
#assert_right(context) ⇒ Object
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
|
# File 'lib/core/nodes.rb', line 695
def assert_right(context)
@right_memory[context.fact.id] = context
if @ref_nodes.empty?
@left_memory.values.flatten.each do |left_context|
propagate_retract_resolve(left_context.match)
end
else
@left_memory.values.flatten.each do |left_context|
if match_ref_nodes(left_context,context)
propagate_retract_resolve(left_context.match)
end
end
end
end
|
#retract_left(fact) ⇒ Object
655
656
657
658
|
# File 'lib/core/nodes.rb', line 655
def retract_left(fact)
@left_memory.delete(fact.id)
propagate_retract(fact)
end
|
#retract_right(fact) ⇒ Object
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
# File 'lib/core/nodes.rb', line 660
def retract_right(fact)
right_context = @right_memory.delete(fact.id)
unless right_context == @right_memory.default
unless @ref_nodes.empty? && !@right_memory.empty?
@left_memory.values.each do |lm|
lm.each do |left_context|
if match_ref_nodes(left_context,right_context)
propagate_assert(left_context)
end
end
end
end
end
end
|