Class: Ruleby::Core::SelfReferenceNode

Inherits:
AtomNode show all
Defined in:
lib/core/nodes.rb

Overview

This node class is used to match properties of a fact with other properties of itself. Unlike ReferenceAtom it does perform inline matching.

Instance Attribute Summary

Attributes inherited from AtomNode

#atom

Attributes inherited from ParentNode

#child_nodes

Attributes inherited from Printable

#parent_nodes

Instance Method Summary collapse

Methods inherited from AtomNode

#==, #initialize, #shareable?, #to_s

Methods inherited from ParentNode

#add_out_node, #forks?, #initialize, #propagate_assert, #propagate_retract, #retract

Methods inherited from Node

#resolve

Methods inherited from Printable

#initialize, #print

Constructor Details

This class inherits a constructor from Ruleby::Core::AtomNode

Instance Method Details

#assert(fact) ⇒ Object



462
463
464
# File 'lib/core/nodes.rb', line 462

def assert(fact)      
  propagate_assert fact if match fact
end

#match(fact) ⇒ Object



466
467
468
469
470
471
472
# File 'lib/core/nodes.rb', line 466

def match(fact)
  args = [fact.object.send(@atom.method)]
  @atom.vars.each do |var|
    args.push fact.object.send(var)   
  end   
  return @atom.proc.call(*args) 
end