Class: Wongi::Engine::OrNode
- Inherits:
-
BetaMemory
- Object
- BetaNode
- BetaMemory
- Wongi::Engine::OrNode
- Defined in:
- lib/wongi-engine/beta/or_node.rb
Instance Attribute Summary collapse
-
#parents ⇒ Object
readonly
Returns the value of attribute parents.
-
#rete ⇒ Object
readonly
Returns the value of attribute rete.
Attributes inherited from BetaMemory
Attributes inherited from BetaNode
Instance Method Summary collapse
- #depth ⇒ Object
- #ident ⇒ Object
-
#initialize(parents) ⇒ OrNode
constructor
A new instance of OrNode.
- #refresh ⇒ Object
Methods inherited from BetaMemory
#beta_activate, #delete_token, #refresh_child, #seed, #subst
Methods inherited from BetaNode
#assignment_node, #beta_memory, #delete_token, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #refresh_child
Methods included from CoreExt
Constructor Details
#initialize(parents) ⇒ OrNode
Returns a new instance of OrNode.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wongi-engine/beta/or_node.rb', line 47 def initialize parents super nil @parents = parents parents.each do |parent| parent.children << self end retes = parents.map( &:rete ).uniq raise "Cannot combine variants from several Retes" if retes.size > 1 @rete = retes.first end |
Instance Attribute Details
#parents ⇒ Object (readonly)
Returns the value of attribute parents.
44 45 46 |
# File 'lib/wongi-engine/beta/or_node.rb', line 44 def parents @parents end |
#rete ⇒ Object (readonly)
Returns the value of attribute rete.
45 46 47 |
# File 'lib/wongi-engine/beta/or_node.rb', line 45 def rete @rete end |
Instance Method Details
#depth ⇒ Object
64 65 66 |
# File 'lib/wongi-engine/beta/or_node.rb', line 64 def depth parents.map( &:depth ).max + 1 end |
#ident ⇒ Object
58 59 60 61 |
# File 'lib/wongi-engine/beta/or_node.rb', line 58 def ident ids = parents.map( &:id ).join ", " "<R> #{self.class} #{id}, parents #{ids}" end |
#refresh ⇒ Object
68 69 70 71 72 |
# File 'lib/wongi-engine/beta/or_node.rb', line 68 def refresh parents.each do |parent| parent.refresh_child self end end |