Class: Wongi::Engine::TraceAction
- Defined in:
- lib/wongi-engine/dsl/actions/trace_action.rb
Defined Under Namespace
Classes: DefaultTracer
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Attributes inherited from Action
#name, #production, #rete, #rule
Instance Method Summary collapse
- #execute(token) ⇒ Object
-
#initialize(opts = { }) ⇒ TraceAction
constructor
A new instance of TraceAction.
- #trace(args) ⇒ Object
Methods included from CoreExt
Constructor Details
#initialize(opts = { }) ⇒ TraceAction
Returns a new instance of TraceAction.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wongi-engine/dsl/actions/trace_action.rb', line 26 def initialize opts = { } [:generation, :values, :tracer, :tracer_class, :io].each do |option| if opts.has_key? option instance_variable_set "@#{option}", opts[option] end end @io ||= $stdout @tracer ||= (@tracer_class || DefaultTracer).new @tracer.action = self end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
23 24 25 |
# File 'lib/wongi-engine/dsl/actions/trace_action.rb', line 23 def io @io end |
Instance Method Details
#execute(token) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/wongi-engine/dsl/actions/trace_action.rb', line 41 def execute token production.tracer = self if values? trace action: self, token: token else trace action: self end end |
#trace(args) ⇒ Object
37 38 39 |
# File 'lib/wongi-engine/dsl/actions/trace_action.rb', line 37 def trace args @tracer.trace args end |