Module: Kernel

Defined in:
lib/sc2ai/overrides/kernel.rb

Overview

Kernel extensions

Class Method Summary collapse

Class Method Details

.silence_warningsObject

Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.

silence_warnings do
  value = noisy_call # no warning voiced
end

noisy_call # warning voiced


19
20
21
# File 'lib/sc2ai/overrides/kernel.rb', line 19

def silence_warnings(&)
  with_warnings(nil, &)
end

.with_warnings(flag) ⇒ Object

Sets $VERBOSE for the duration of the block and back to its original value afterwards. noinspection RubyGlobalVariableNamingConvention



26
27
28
29
30
31
32
# File 'lib/sc2ai/overrides/kernel.rb', line 26

def with_warnings(flag)
  old_verbose = $VERBOSE
  $VERBOSE = flag
  yield
ensure
  $VERBOSE = old_verbose
end