Class: Wongi::Engine::OptionalNode
- Defined in:
- lib/wongi-engine/beta/optional_node.rb
Instance Attribute Summary
Attributes inherited from JoinNode
#alpha, #assignment_pattern, #tests
Attributes inherited from BetaNode
Instance Method Summary collapse
Methods inherited from JoinNode
compile, #equivalent?, #initialize
Methods inherited from BetaNode
#beta_memory, #depth, #filter_node, #initialize, #join_node, #ncc_node, #neg_node, #network, #optional_node, #update_above
Methods included from CoreExt
Constructor Details
This class inherits a constructor from Wongi::Engine::JoinNode
Instance Method Details
#left_activate(token) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wongi-engine/beta/optional_node.rb', line 23 def left_activate token match = false alpha.wmes.each do |wme| assignments = collect_assignments(wme) if matches? token, wme match = true propagate_activation(token, wme, assignments) jr = OptionalJoinResult.new token, wme token.opt_join_results << jr wme.opt_join_results << jr end end unless match token.has_optional = true propagate_activation(token, nil, {}) end end |
#right_activate(wme) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wongi-engine/beta/optional_node.rb', line 8 def right_activate wme parent.tokens.each do |token| if matches? token, wme if token.has_optional? token.has_optional = false token.delete_children end propagate_activation(token, wme, collect_assignments(wme)) jr = OptionalJoinResult.new token, wme token.opt_join_results << jr wme.opt_join_results << jr end end end |