In this answer, I have shared Tell Ruby Program to Wait some amount of time.
1 | sleep(num_secs) |
The num_secs
value can be an integer or float.
Also, if you’re writing this within a Rails app, or have included the ActiveSupport library in your project, you can construct longer intervals using the following convenience syntax:
1 2 3 4 5 | sleep(4.minutes) # or, even longer... sleep(2.hours); sleep(3.days) # etc., etc. # or shorter sleep(0.5) # half a second |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.