| | |
Exit loop after sometime
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
![]() |
•
•
Join Date: Apr 2009
Posts: 1
Reputation:
Solved Threads: 0
please excuse me, i'm not a developer but a tester and i'm no good at doing programming stuff and all. im into automation now for my testing and i choose to use ruby for it but i have a problem hope you guys could help me out of this...
i need to do a script that will check my email every 5minutes and after 20minutes of no new mail it will produce "test fail". i have found a cool code for checking email every 5min but i could not find a way to stop it after 20minutes? any help is greatly appreciated
here's the code:
i need to do a script that will check my email every 5minutes and after 20minutes of no new mail it will produce "test fail". i have found a cool code for checking email every 5min but i could not find a way to stop it after 20minutes? any help is greatly appreciated

here's the code:
ruby Syntax (Toggle Plain Text)
def time_block start_time = Time.now Thread.new { yield } Time.now - start_time end def repeat_every(seconds) begin time_spent = time_block { yield } sleep(seconds - time_spent) end while time_spent < seconds end repeat_every(300) { # checking of email ever 5 minutes puts "Start checking: #{Time.now}" # email checking here puts "End checking: #{Time.now}" }
Last edited by peter_budo; Apr 9th, 2009 at 7:34 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- How to exit a loop (C++)
- while loop (Java)
- exiting loop with switch (C++)
- Loop troubles (C++)
- Alright this loop problem is bugging me (Java)
- help me understand end of do while loop (C++)
Other Threads in the Ruby Forum
- Previous Thread: Ruby - GUI - Desktop Programming - Tools required
- Next Thread: Configure SciTE - accept keyboard inut
| Thread Tools | Search this Thread |





