Module: Treat::Helpers::Object::Verbosity
- Defined in:
- lib/treat/helpers/object.rb
Instance Method Summary collapse
-
#silence_stdout(log = '/dev/null') ⇒ Object
Runs a block of code while blocking stdout.
-
#silence_warnings(&block) ⇒ Object
Runs a block of code without warnings.
Instance Method Details
#silence_stdout(log = '/dev/null') ⇒ Object
Runs a block of code while blocking stdout.
34 35 36 37 38 39 40 41 |
# File 'lib/treat/helpers/object.rb', line 34 def silence_stdout(log = '/dev/null') unless Treat.core.verbosity.silence yield; return end file, old, ret = File.new(log, 'w'), $stdout.dup, nil; $stdout.reopen(file) ret = yield; $stdout = old; return ret end |
#silence_warnings(&block) ⇒ Object
Runs a block of code without warnings.
28 29 30 31 32 |
# File 'lib/treat/helpers/object.rb', line 28 def silence_warnings(&block) warn_level = $VERBOSE; $VERBOSE = nil result = block.call; $VERBOSE = warn_level result end |