Class: Ruleby::Core::BridgeNode
- Inherits:
-
ParentNode
- Object
- Printable
- Node
- ParentNode
- Ruleby::Core::BridgeNode
- Defined in:
- lib/core/nodes.rb
Overview
The BridgeNode is used to bridge the alpha network to either the beta network, or to the terminal nodes. It creates a partial match from the pattern and atoms above it in the network. Thus, there is one bridge node for each pattern (assuming they aren’t shared).
Instance Attribute Summary
Attributes inherited from ParentNode
Attributes inherited from Printable
Instance Method Summary collapse
-
#initialize(pattern) ⇒ BridgeNode
constructor
A new instance of BridgeNode.
- #propagate_assert(fact) ⇒ Object
Methods inherited from ParentNode
#add_out_node, #assert, #forks?, #propagate_retract, #retract
Methods inherited from Node
Methods inherited from Printable
Constructor Details
#initialize(pattern) ⇒ BridgeNode
Returns a new instance of BridgeNode.
480 481 482 483 |
# File 'lib/core/nodes.rb', line 480 def initialize(pattern) super() @pattern = pattern end |
Instance Method Details
#propagate_assert(fact) ⇒ Object
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/core/nodes.rb', line 485 def propagate_assert(fact) # create the partial match mr = MatchResult.new mr.is_match = true mr.recency.push fact.recency @pattern.atoms.each do |atom| mr.fact_hash[atom.tag] = fact.id if atom == @pattern.head # HACK its a pain to have to check for this, can we make it special mr[atom.tag] = fact.object else mr[atom.tag] = fact.object.send(atom.method) end end super(MatchContext.new(fact,mr)) end |