Class: Ruleby::Core::Node

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

Overview

Base Node class used by all nodes in the network that do some kind of matching.

Direct Known Subclasses

ParentNode, TerminalNode

Instance Attribute Summary

Attributes inherited from Printable

#parent_nodes

Instance Method Summary collapse

Methods inherited from Printable

#print

Constructor Details

#initialize(bucket) ⇒ Node

Returns a new instance of Node.



278
279
280
281
# File 'lib/core/nodes.rb', line 278

def initialize(bucket)
  super()
  @bucket = bucket
end

Instance Method Details

#resolve(mr1, mr2) ⇒ Object

This method determines if all common tags have equal values. If any values are not equal then the method returns false.



285
286
287
288
289
290
291
292
293
294
# File 'lib/core/nodes.rb', line 285

def resolve(mr1, mr2)    
  mr1.variables.each_key do |t1|
    mr2.variables.each_key do |t2|
      if t2 == t1 && mr1.fact_hash[t1] != mr2.fact_hash[t2]
        return false 
      end
    end
  end 
  true
end