Class: Grell::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/grell/reader.rb

Overview

A tooling class, it waits a maximum of max_waiting for an action to finish. If the action is not finished by then, it will continue anyway. The wait may be long but we want to finish it as soon as the action has finished

Class Method Summary collapse

Class Method Details

.wait_for(action, max_waiting, sleeping_time) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/grell/reader.rb', line 6

def self.wait_for(action, max_waiting, sleeping_time)
  time_start = Time.now
  action.call()
  return if yield
  while (Time.now < time_start + max_waiting)
    action.call()
    break if yield
    sleep(sleeping_time)
  end
end