On Fri, 6 Jan 2006, Carlos Delmar wrote: > For example I would like to remove puts from the process_transaction > method and the do this: > > transactions.each do |member| > puts process_transaction(member) > end > > (sorry for the messy line breaks!) > > -- > Posted via http://www.ruby-forum.com/. it's not puts that you need to mess with - it's stdout that needs capturing: harp:~ > cat a.rb require "yaml" require "stringio" def buffering_stdout stdout, sio = $stdout, StringIO::new begin $stdout = sio yield sio.rewind sio.read ensure $stdout = stdout end end stdout = buffering_stdout do puts 42 p 42 printf "%d\n", 42 end y "stdout" => stdout harp:~ > ruby a.rb stdout: | 42 42 42 regards. -a -- =============================================================================== | ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================