From: Daniel Lucraft Date: 2008-08-23T00:16:01+09:00 Subject: Re: temporarily redefine the 'puts' command? aidy wrote: > Hi, > > Is it possible to temporarily redefine the 'puts' command? > > I have a gem that unnecessarily writes to the console, which effects > the Rspec Story Runner logging, > > I do not want to manual comment out the puts as I use this gem on > numerous machines > > Aidy $ irb irb(main):001:0> alias :oldputs :puts => nil irb(main):002:0> def puts(*args); end => nil irb(main):003:0> puts "hi" => nil irb(main):004:0> alias :puts :oldputs => nil irb(main):005:0> puts "hi" hi => nil howzat? You probably want to explicitly do it in Kernel when you do it for real. Something like this, if you need to do it dynamically. eval %Q{ module Kernel alias :oldputs :puts def puts(*args) end end } best, Dan -- Posted via http://www.ruby-forum.com/.