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, #initialize, #modify, #propagate, #propagate_assert, #propagate_modify, #propagate_retract, #retract

Methods inherited from Node

#initialize, #resolve

Methods inherited from Printable

#initialize, #print

Constructor Details

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

Instance Method Details

#assert(assertable) ⇒ Object



556
557
558
# File 'lib/core/nodes.rb', line 556

def assert(assertable)
  propagate_assert assertable if match assertable.fact
end

#match(fact) ⇒ Object



560
561
562
563
564
565
566
# File 'lib/core/nodes.rb', line 560

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