From: Brian Candler Date: 2010-06-28T22:18:55+09:00 Subject: Re: pretty inspecting objects? Jarmo Pertman wrote: > Idea would be to write contents of some objects into some file in pretty > inspection format. > > How is it possible in Ruby to get pretty inspection of an object without > printing it to stdout? > > One possibility would be to play with stdout redirection while using > 'pp', but that's not what i'm looking for. Is there any easy way to do > it or should i start monkey-patching 'pp' to add that feature? Why monkey-patch? Look at source of pp.rb, and you'll see it takes an optional argument, out=$> require 'pp' a = {:foo=>1,:bar=>2} File.open("/tmp/pp.out","w") { |f| PP.pp(a, f) } -- Posted via http://www.ruby-forum.com/.