Class: DecisionAgent::Simulation::ScenarioEngine::ProgressTracker
- Inherits:
-
Object
- Object
- DecisionAgent::Simulation::ScenarioEngine::ProgressTracker
- Defined in:
- lib/decision_agent/simulation/scenario_engine.rb
Overview
Helper class for tracking progress
Instance Method Summary collapse
- #increment ⇒ Object
-
#initialize(total, callback) ⇒ ProgressTracker
constructor
A new instance of ProgressTracker.
Constructor Details
#initialize(total, callback) ⇒ ProgressTracker
95 96 97 98 99 |
# File 'lib/decision_agent/simulation/scenario_engine.rb', line 95 def initialize(total, callback) @total = total @callback = callback @completed = 0 end |
Instance Method Details
#increment ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/decision_agent/simulation/scenario_engine.rb', line 101 def increment @completed += 1 return unless @callback @callback.call( completed: @completed, total: @total, percentage: (@completed.to_f / @total * 100).round(2) ) end |