Class: Ruleby::Core::AtomNode

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

Overview

This is a base class for all single input nodes that match facts based on some properties. It is essentially a wrapper for an Atom. These nodes make up the Alpha network.

Instance Attribute Summary collapse

Attributes inherited from ParentNode

#child_nodes

Attributes inherited from Printable

#parent_nodes

Instance Method Summary collapse

Methods inherited from ParentNode

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

Methods inherited from Node

#resolve

Methods inherited from Printable

#print

Constructor Details

#initialize(atom) ⇒ AtomNode

Returns a new instance of AtomNode.



330
331
332
333
# File 'lib/core/nodes.rb', line 330

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

Instance Attribute Details

#atomObject (readonly)

Returns the value of attribute atom.



329
330
331
# File 'lib/core/nodes.rb', line 329

def atom
  @atom
end

Instance Method Details

#==(node) ⇒ Object



335
336
337
# File 'lib/core/nodes.rb', line 335

def ==(node)
  return AtomNode === node && @atom == node.atom
end

#shareable?(node) ⇒ Boolean

Returns:

  • (Boolean)


339
340
341
# File 'lib/core/nodes.rb', line 339

def shareable?(node)
  return @atom.shareable?(node.atom)
end

#to_sObject



343
344
345
# File 'lib/core/nodes.rb', line 343

def to_s
  super + " - #{@atom.method}"
end