Class: Ruleby::Core::PropertyNode

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

Overview

This node class is used for matching properties of a fact.

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



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/core/nodes.rb', line 409

def assert(fact)
  begin
    val = fact.object.send(@atom.method)   
  rescue NoMethodError => e
    # If the method does not exist, it is the same as if it evaluted to 
    # false, and the network traverse stops
    return
  end
  begin
    super if @atom.proc.call(val)
  rescue Exception => e
    # There is a bug in Ruby MRI that goes away when we call print.  Even if the following
    # line of code is never executed at runtime.  The problem does not exist in JRuby
    print ''
    raise ProcessInvocationError.new(e), e.message
  end
end