Skip to content

Instantly share code, notes, and snippets.

@misku
misku / gist:ef2ae4a10eb338ebd93b
Created July 18, 2014 10:30
Prevent output of command triggered
def self.preventOutput(msg)
exeption = false
# Prevent block from outputting anything
original_stdout = $stdout
$stdout = fake = StringIO.new
begin
# Peform the action
yield if block_given?
rescue Exception => e
exeption = true