Skip to content

Instantly share code, notes, and snippets.

@rebelwarrior
Created January 24, 2018 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebelwarrior/1d324c21a78046ce19a01c1452597bdb to your computer and use it in GitHub Desktop.
Save rebelwarrior/1d324c21a78046ce19a01c1452597bdb to your computer and use it in GitHub Desktop.
Supresses Output to Terminal in Ruby
# from https://gist.github.com/iamtheiconoclast
# on https://gist.github.com/moertel/11091573
def suppress_output
original_stdout, original_stderr = $stdout.clone, $stderr.clone
$stderr.reopen File.new('/dev/null', 'w')
$stdout.reopen File.new('/dev/null', 'w')
yield
ensure
$stdout.reopen original_stdout
$stderr.reopen original_stderr
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment