Skip to content

Instantly share code, notes, and snippets.

@rebelwarrior
Created January 24, 2018 15:46
Show Gist options
  • Select an option

  • Save rebelwarrior/1d324c21a78046ce19a01c1452597bdb to your computer and use it in GitHub Desktop.

Select an option

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