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 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, #beta_deactivate, #refresh_child, #seed, #subst
Methods inherited from BetaNode
#assignment_node, #delete_token, #refresh_child, #root?
Methods included from CoreExt
Constructor Details
#initialize(parents) ⇒ OrNode
Returns a new instance of OrNode.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/wongi-engine/beta/or_node.rb', line 8 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.
5 6 7 |
# File 'lib/wongi-engine/beta/or_node.rb', line 5 def parents @parents end |
#rete ⇒ Object (readonly)
Returns the value of attribute rete.
6 7 8 |
# File 'lib/wongi-engine/beta/or_node.rb', line 6 def rete @rete end |
Instance Method Details
#depth ⇒ Object
25 26 27 |
# File 'lib/wongi-engine/beta/or_node.rb', line 25 def depth parents.map( &:depth ).max + 1 end |
#ident ⇒ Object
19 20 21 22 |
# File 'lib/wongi-engine/beta/or_node.rb', line 19 def ident ids = parents.map( &:id ).join ", " "<R> #{self.class} #{id}, parents #{ids}" end |
#refresh ⇒ Object
29 30 31 32 33 |
# File 'lib/wongi-engine/beta/or_node.rb', line 29 def refresh parents.each do |parent| parent.refresh_child self end end |