title: Perform a loop for a certain time interval or while condition is met
body: <p>I am trying to have a check fire off every second for 30 seconds. I haven't found a clear way to do this with Ruby yet. Trying something like this currently:</p>
  
  <pre><code>until counter == 30
    sleep 1
    if condition
      do something
      break
     else
       counter +=1
  end
  </code></pre>
  
  <p>Problem with something like that is it has to use sleep, which stops the thread in its tracks for a full second. Is there another way to achieve something similar to the above without the use of sleep? Is there a way to have something cycle though on a time based interval?</p>