Class: Ruleby::Core::ReferenceNode
- Defined in:
- lib/core/nodes.rb
Overview
This node class is used to match properties of one with the properties of any other already matched fact. It differs from the other AtomNodes because it does not perform any inline matching. The match method is only invoked by the two input node.
Instance Attribute Summary
Attributes inherited from AtomNode
Attributes inherited from ParentNode
Attributes inherited from Printable
Instance Method Summary collapse
Methods inherited from AtomNode
#==, #initialize, #shareable?, #to_s
Methods inherited from ParentNode
#add_out_node, #assert, #forks?, #initialize, #propagate_assert, #propagate_retract, #retract
Methods inherited from Node
Methods inherited from Printable
Constructor Details
This class inherits a constructor from Ruleby::Core::AtomNode
Instance Method Details
#match(left_context, right_fact) ⇒ Object
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/core/nodes.rb', line 435 def match(left_context,right_fact) val = right_fact.object.send(@atom.method) args = [val] match = left_context.match @atom.vars.each do |var| args.push match.variables[var] end begin if @atom.proc.call(*args) m = MatchResult.new(match.variables.clone, true, match.fact_hash.clone, match.recency) m.recency.push right_fact.recency m.fact_hash[@atom.tag] = right_fact.id m.variables[@atom.tag] = val return m end rescue NoMethodError => e # If the method does not exist, it is the same as if it evaluted to # false, and the network traverse stops end return MatchResult.new end |