Class: Wongi::Engine::FilterNode

Inherits:
BetaNode
  • Object
show all
Defined in:
lib/wongi-engine/beta/filter_node.rb

Instance Attribute Summary collapse

Attributes inherited from BetaNode

#children, #parent, #rete

Instance Method Summary collapse

Methods inherited from BetaNode

#assignment_node, #beta_memory, #delete_token, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #refresh

Methods included from CoreExt

included

Constructor Details

#initialize(parent, test) ⇒ FilterNode

Returns a new instance of FilterNode.



8
9
10
11
# File 'lib/wongi-engine/beta/filter_node.rb', line 8

def initialize parent, test
  super parent
  self.test = test
end

Instance Attribute Details

#testObject

Returns the value of attribute test.



6
7
8
# File 'lib/wongi-engine/beta/filter_node.rb', line 6

def test
  @test
end

Instance Method Details

#beta_activate(token, wme = nil, assignments = { }) ⇒ Object



13
14
15
16
17
# File 'lib/wongi-engine/beta/filter_node.rb', line 13

def beta_activate token, wme = nil, assignments = { }
  if test.passes? token
    propagate_activation token, nil, {}
  end
end

#equivalent?(test) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/wongi-engine/beta/filter_node.rb', line 19

def equivalent? test
  test == self.test
end

#refresh_child(child) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/wongi-engine/beta/filter_node.rb', line 23

def refresh_child child
  tmp = children
  self.children = [ child ]
  parent.tokens.each do |token|
    beta_activate token
  end
  self.children = tmp
end