#reset is still making the timer fail in 1.11.0
The problem was already presented in issue #160, and seems to still be present in 1.11.0.
There is a good chance of the progressbar failing when using the method #reset. As before, the code seemingly in error is:
https://github.com/jfelchner/ruby-progressbar/blob/043d5a8a7abc18dad4b8dc57b3cc3c8a5f701a07/lib/ruby-progressbar/timer.rb#L54
While the component time was fixed, this time it's the component :rate which indirectly calls #elapsed_seconds, and since the timer was reset, :started_at is nil. You can once again reproduce this error with the following code (since rate is the issue, it's been isolated in the format string):
require 'ruby-progressbar'
p = ProgressBar.create(format: '%R')
100.times { p.increment; sleep(0.01) }
p.reset
p.total = 50
50.times { p.increment; sleep(0.01) }
I suppose the most straightforward fix would be to change: https://github.com/jfelchner/ruby-progressbar/blob/cd4f57a1f1ff75e2cb1b83c7d241a108ac9ad7ad/lib/ruby-progressbar/components/rate.rb#L21 to something like
return 0 if timer.started_at.nil? || !elapsed_seconds.positive?
I am running ruby-progressbar v. 1.11.0 with ruby 2.5.5.
@eleanorcuallado awesome. Thank you for the report and the reproduction example!
@eleanorcuallado I haven't forgotten about this. I'll get a new release out in December.
@eleanorcuallado finally got to this! Thank you again!