Class: SpotFlow::ExecutionPrinter
- Inherits:
-
Object
- Object
- SpotFlow::ExecutionPrinter
- Defined in:
- lib/spot_flow/execution.rb
Instance Attribute Summary collapse
-
#execution ⇒ Object
Returns the value of attribute execution.
Instance Method Summary collapse
-
#initialize(execution) ⇒ ExecutionPrinter
constructor
A new instance of ExecutionPrinter.
- #print ⇒ Object
- #print_child(child, index) ⇒ Object
- #print_children ⇒ Object
- #print_variables ⇒ Object
Constructor Details
#initialize(execution) ⇒ ExecutionPrinter
Returns a new instance of ExecutionPrinter.
326 327 328 |
# File 'lib/spot_flow/execution.rb', line 326 def initialize(execution) @execution = execution end |
Instance Attribute Details
#execution ⇒ Object
Returns the value of attribute execution.
324 325 326 |
# File 'lib/spot_flow/execution.rb', line 324 def execution @execution end |
Instance Method Details
#print ⇒ Object
330 331 332 333 334 335 336 |
# File 'lib/spot_flow/execution.rb', line 330 def print puts puts "#{execution.step.id} #{execution.status} * #{execution.tokens.join(', ')}" print_variables unless execution.variables.empty? print_children puts end |
#print_child(child, index) ⇒ Object
345 346 347 348 349 350 351 352 353 |
# File 'lib/spot_flow/execution.rb', line 345 def print_child(child, index) str = "#{index} #{child.step.class.name.demodulize} #{child.step.id}: #{child.status} #{JSON.pretty_generate(child.variables, { indent: '', object_nl: ' ' }) unless child.variables.empty? }".strip str = "#{str} * in: #{child.tokens_in.join(', ')}" if child.tokens_in.present? str = "#{str} * out: #{child.tokens_out.join(', ')}" if child.tokens_out.present? puts str child.children.each_with_index do |grandchild, grandindex| print_child(grandchild, "#{index}.#{grandindex}") end end |
#print_children ⇒ Object
338 339 340 341 342 343 |
# File 'lib/spot_flow/execution.rb', line 338 def print_children puts execution.children.each_with_index do |child, index| print_child(child, index) end end |
#print_variables ⇒ Object
355 356 357 358 |
# File 'lib/spot_flow/execution.rb', line 355 def print_variables puts puts JSON.pretty_generate(execution.variables) end |