Prettyprint or pp questions

There are three things I would like to do but I am not
sure how:

1. Redirect the output to another IO -- something like

        STDERR.pp obj

2. Retrieve the text without printing it (analogous to #inspect):

        str = obj.pretty # or whatever

3. Add pp functionality to the Date class. This doesn't work:

         class Date
           def pretty_print
             inspect
           end
         end

Thanks for assistance...

Hal

1. Redirect the output to another IO -- something like
        STDERR.pp obj

  PP.pp(obj, STDERR) # or change $>

2. Retrieve the text without printing it (analogous to #inspect):
        str = obj.pretty # or whatever

   str = ""; PP.pp(obj, str)

3. Add pp functionality to the Date class. This doesn't work:

         class Date
           def pretty_print(obj)
             inspect

                obj.pp(inspect)

           end
         end

Guy Decoux

There are three things I would like to do but I am not
sure how:

2. Retrieve the text without printing it (analogous to #inspect):

        str = obj.pretty # or whatever

  require 'extensions/object'
  str = obj.pp_s

1. Redirect the output to another IO -- something like

        STDERR.pp obj

  STDERR.puts obj.pp_s

Cheers,
Gavin

P.S. It seems to me that all the questions you're asking should be
more elegantly solved by the 'pp' library. That it, it should all
"just work".

···

On Thursday, November 25, 2004, 10:37:16 PM, Hal wrote:

ts wrote:

"H" == Hal Fulton <hal9000@hypermetrics.com> writes:

[snip solutions]

Merci beaucoups, M'sieur Decoux...

Hal