Class: DecisionAgent::Simulation::ShadowTestEngine::ProgressTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/decision_agent/simulation/shadow_test_engine.rb

Overview

Helper class for tracking progress

Instance Method Summary collapse

Constructor Details

#initialize(total, callback) ⇒ ProgressTracker

Returns a new instance of ProgressTracker.



130
131
132
133
134
# File 'lib/decision_agent/simulation/shadow_test_engine.rb', line 130

def initialize(total, callback)
  @total = total
  @callback = callback
  @completed = 0
end

Instance Method Details

#incrementObject



136
137
138
139
140
141
142
143
144
145
# File 'lib/decision_agent/simulation/shadow_test_engine.rb', line 136

def increment
  @completed += 1
  return unless @callback

  @callback.call(
    completed: @completed,
    total: @total,
    percentage: (@completed.to_f / @total * 100).round(2)
  )
end