Class: Wongi::Engine::OrNode

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

Instance Attribute Summary collapse

Attributes inherited from BetaMemory

#last_token, #tokens

Attributes inherited from BetaNode

#children, #parent

Instance Method Summary collapse

Methods inherited from BetaMemory

#left_activate, #seed, #subst

Methods inherited from BetaNode

#beta_memory, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node

Methods included from CoreExt

included

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

#parentsObject (readonly)

Returns the value of attribute parents.



44
45
46
# File 'lib/wongi-engine/beta/or_node.rb', line 44

def parents
  @parents
end

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

#depthObject



64
65
66
# File 'lib/wongi-engine/beta/or_node.rb', line 64

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

#identObject



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

#update_aboveObject



68
69
70
71
72
# File 'lib/wongi-engine/beta/or_node.rb', line 68

def update_above
  parents.each do |parent|
    update_from parent
  end
end