Class: Wongi::Engine::ProductionNode
- Defined in:
- lib/wongi-engine/beta/production_node.rb
Instance Attribute Summary collapse
-
#compilation_context ⇒ Object
Returns the value of attribute compilation_context.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tracer ⇒ Object
Returns the value of attribute tracer.
Attributes inherited from BetaNode
Instance Method Summary collapse
- #beta_activate(token) ⇒ Object
- #beta_deactivate(token) ⇒ Object
-
#initialize(name, parent, actions) ⇒ ProductionNode
constructor
A new instance of ProductionNode.
Methods inherited from BetaNode
#assignment_node, #beta_deactivate_children, #depth, #empty?, #overlay, #refresh, #root?, #size, #tokens
Methods included from CoreExt
Constructor Details
#initialize(name, parent, actions) ⇒ ProductionNode
Returns a new instance of ProductionNode.
6 7 8 9 10 |
# File 'lib/wongi-engine/beta/production_node.rb', line 6 def initialize(name, parent, actions) super(parent) @actions = actions.each { |action| action.production = self } @name = name end |
Instance Attribute Details
#compilation_context ⇒ Object
Returns the value of attribute compilation_context.
4 5 6 |
# File 'lib/wongi-engine/beta/production_node.rb', line 4 def compilation_context @compilation_context end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/wongi-engine/beta/production_node.rb', line 4 def name @name end |
#tracer ⇒ Object
Returns the value of attribute tracer.
4 5 6 |
# File 'lib/wongi-engine/beta/production_node.rb', line 4 def tracer @tracer end |
Instance Method Details
#beta_activate(token) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wongi-engine/beta/production_node.rb', line 12 def beta_activate(token) # p beta_activate: {class: self.class, object_id:, token:} return if tokens.find { |t| t.duplicate? token } .add_token(token) @actions.each do |action| action.execute token if action.respond_to? :execute end end |
#beta_deactivate(token) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wongi-engine/beta/production_node.rb', line 23 def beta_deactivate(token) # p beta_deactivate: {class: self.class, object_id:, token:} # we should remove before the actions because otherwise the longer rule chains (like the infinite neg-gen cycle) don't work as expected .remove_token(token) @actions.each do |action| action.deexecute token if action.respond_to? :deexecute end end |