Class: Wongi::Engine::OrNode

Inherits:
BetaMemory show all
Defined in:
lib/wongi-engine/beta/or_node.rb

Instance Attribute Summary collapse

Attributes inherited from BetaNode

#children, #parent

Instance Method Summary collapse

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

included

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

#parentsObject (readonly)

Returns the value of attribute parents.



5
6
7
# File 'lib/wongi-engine/beta/or_node.rb', line 5

def parents
  @parents
end

#reteObject (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

#depthObject



25
26
27
# File 'lib/wongi-engine/beta/or_node.rb', line 25

def depth
  parents.map( &:depth ).max + 1
end

#identObject



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

#refreshObject



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