Module: KKernel
- Included in:
- Object
- Defined in:
- lib/kyanite/general/kernel.rb
Overview
Instance Method Summary collapse
-
#repeat_n_seconds(n = 1, &block) ⇒ Object
Repeats a block until the time is up.
-
#silence_warnings ⇒ Object
Silence all Ruby warnings for the following block.
Instance Method Details
#repeat_n_seconds(n = 1, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kyanite/general/kernel.rb', line 27 def repeat_n_seconds( n=1, &block ) timer = Timer.new(n) begin timer.start count = 0 until false count += 1 yield block if block end timer.stop rescue TimeoutError return count rescue return count rescue return count end # begin end |
#silence_warnings ⇒ Object
58 59 60 61 62 63 |
# File 'lib/kyanite/general/kernel.rb', line 58 def silence_warnings old_verbose, $VERBOSE = $VERBOSE, nil yield ensure $VERBOSE = old_verbose end |