Class: EvalRuby::Progress

Inherits:
Struct
  • Object
show all
Defined in:
lib/eval_ruby.rb

Overview

Progress snapshot yielded to the block passed to evaluate_batch.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#currentObject (readonly)

number of samples completed (1-indexed)



58
59
60
61
62
63
# File 'lib/eval_ruby.rb', line 58

Progress = Struct.new(:current, :total, :elapsed, keyword_init: true) do
  # @return [Float] completion percentage, 0.0–100.0
  def percent
    total.zero? ? 0.0 : (current.to_f / total * 100).round(2)
  end
end

#totalObject (readonly)

total samples in the batch



58
59
60
61
62
63
# File 'lib/eval_ruby.rb', line 58

Progress = Struct.new(:current, :total, :elapsed, keyword_init: true) do
  # @return [Float] completion percentage, 0.0–100.0
  def percent
    total.zero? ? 0.0 : (current.to_f / total * 100).round(2)
  end
end

Instance Method Details

#elapsed=(value) ⇒ Object

seconds since batch started



58
59
60
61
62
63
# File 'lib/eval_ruby.rb', line 58

Progress = Struct.new(:current, :total, :elapsed, keyword_init: true) do
  # @return [Float] completion percentage, 0.0–100.0
  def percent
    total.zero? ? 0.0 : (current.to_f / total * 100).round(2)
  end
end

#percentFloat

Returns completion percentage, 0.0–100.0.

Returns:

  • (Float)

    completion percentage, 0.0–100.0



60
61
62
# File 'lib/eval_ruby.rb', line 60

def percent
  total.zero? ? 0.0 : (current.to_f / total * 100).round(2)
end