I have this as a lone method, but it seems to me there should already
be a way to do this with the 'pp' lib. (If not perhaps we could add
it?)


require 'pp'
require 'stringio'

module Kernel

  # Returns a pretty-printed string of the object.  Requires libraries
+pp+ and
  # +stringio+ from the Ruby standard library.
  #
  # The following code pretty-prints an object (much like +p+ plain-
prints an
  # object):
  #
  #   pp object
  #
  # The following code captures the pretty-printing in +str+ instead
of
  # sending it to +STDOUT+.
  #
  #   str = object.pp_s
  #
  #   CREDIT Noah Gibbs
  #   CREDIT Gavin Sinclair

  def pp_s
    pps = StringIO.new
    PP.pp(self, pps)
    pps.string
  end

end