We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Async::Clock#reset!
1 parent eff526c commit 542c739Copy full SHA for 542c739
lib/async/clock.rb
@@ -61,5 +61,14 @@ def total
61
62
return total
63
end
64
+
65
+ # Reset the total elapsed time. If the clock is currently running, reset the start time to now.
66
+ def reset!
67
+ @total = 0
68
69
+ if @started
70
+ @started = Clock.now
71
+ end
72
73
74
test/async/clock.rb
@@ -58,4 +58,22 @@
58
expect(total).to be >= 0.0
59
60
+ with "#reset!" do
+ it "resets the total time" do
+ clock.start!
+ sleep(0.0001)
+ clock.stop!
+ expect(clock.total).to be > 0.0
+ clock.reset!
+ expect(clock.total).to be == 0.0
+ it "resets the start time" do
75
76
77
78
79
0 commit comments