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

Methods inherited from Node

#resolve

Methods inherited from Printable

#print

Constructor Details

#initialize(bucket, atom) ⇒ AtomNode

Returns a new instance of AtomNode.



363
364
365
366
# File 'lib/core/nodes.rb', line 363

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

Instance Attribute Details

#atomObject (readonly)

Returns the value of attribute atom.



362
363
364
# File 'lib/core/nodes.rb', line 362

def atom
  @atom
end

Instance Method Details

#==(node) ⇒ Object



368
369
370
# File 'lib/core/nodes.rb', line 368

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

#shareable?(node) ⇒ Boolean

Returns:

  • (Boolean)


372
373
374
# File 'lib/core/nodes.rb', line 372

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

#to_sObject



376
377
378
# File 'lib/core/nodes.rb', line 376

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