Class: Ruleby::Core::ParentNode
- Defined in:
- lib/core/nodes.rb
Overview
This is the base class for all nodes in the network that output to some other node (i.e. they are not at the bottom). It contains methods for propagating match results.
Direct Known Subclasses
AtomNode, BridgeNode, JoinNode, LeftAdapterNode, RightAdapterNode
Instance Attribute Summary collapse
-
#child_nodes ⇒ Object
readonly
Returns the value of attribute child_nodes.
Attributes inherited from Printable
Instance Method Summary collapse
- #add_out_node(node, atom = nil) ⇒ Object
- #assert(assertable) ⇒ Object
-
#forks?(atom) ⇒ Boolean
returns true if this node is already being used for the same atom.
-
#initialize ⇒ ParentNode
constructor
A new instance of ParentNode.
- #propagate_assert(assertable, out_nodes = @out_nodes) ⇒ Object
- #propagate_retract(fact, out_nodes = @out_nodes) ⇒ Object
- #retract(fact) ⇒ Object
Methods inherited from Node
Methods inherited from Printable
Constructor Details
#initialize ⇒ ParentNode
Returns a new instance of ParentNode.
286 287 288 289 |
# File 'lib/core/nodes.rb', line 286 def initialize() super @out_nodes = [] end |
Instance Attribute Details
#child_nodes ⇒ Object (readonly)
Returns the value of attribute child_nodes.
285 286 287 |
# File 'lib/core/nodes.rb', line 285 def child_nodes @child_nodes end |
Instance Method Details
#add_out_node(node, atom = nil) ⇒ Object
291 292 293 294 295 |
# File 'lib/core/nodes.rb', line 291 def add_out_node(node,atom=nil) unless @out_nodes.index node @out_nodes.push node end end |
#assert(assertable) ⇒ Object
314 315 316 |
# File 'lib/core/nodes.rb', line 314 def assert(assertable) propagate_assert(assertable) end |
#forks?(atom) ⇒ Boolean
returns true if this node is already being used for the same atom. That is, if it is used again it will fork the network (or the network may already be forked).
300 301 302 |
# File 'lib/core/nodes.rb', line 300 def forks?(atom) return !@out_nodes.empty? end |
#propagate_assert(assertable, out_nodes = @out_nodes) ⇒ Object
318 319 320 321 322 |
# File 'lib/core/nodes.rb', line 318 def propagate_assert(assertable,out_nodes=@out_nodes) out_nodes.each do |out_node| out_node.assert(assertable) end end |
#propagate_retract(fact, out_nodes = @out_nodes) ⇒ Object
308 309 310 311 312 |
# File 'lib/core/nodes.rb', line 308 def propagate_retract(fact,out_nodes=@out_nodes) out_nodes.each do |out_node| out_node.retract(fact) end end |
#retract(fact) ⇒ Object
304 305 306 |
# File 'lib/core/nodes.rb', line 304 def retract(fact) propagate_retract(fact) end |