I've been using this guy for code that prints copious output to the
terminal. I'm sure it could be improved a bit, but I've found it
useful.
def less
require 'stringio'
$stdout, sout = StringIO.new, $stdout
yield
$stdout, str_io = sout, $stdout
IO.popen('less', 'w') do |f|
f.write str_io.string
f.flush
f.close_write
end
end
I tend to use that in conjunction with yaml dumps to look at complex
data structures, rather than pp, but that would work just as well.
def yp(*data)
require 'yaml'
puts YAML::dump(*data)
end
Give them a whirl like so:
$ irb
less { yp IRB.conf }
--
Lou.