Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Ruby
Posted by: user1fc63
Added: Sep 24, 2018 12:09 PM
Views: 5
Tags: no tags
  1. def wait_while(timeout = 2, retry_interval = 0.1, &block)
  2.   start = Time.now
  3.   while (result = !!block.call)
  4.     break if (Time.now - start).to_i >= timeout
  5.     sleep(retry_interval)
  6.   end
  7.   !result
  8. end