Pp equiv of #inspect


(Ara.T.Howard) #1

i often use

raise SomeError, “object was <#{ object.inspect }>”

and similar

what would be the eqiv methods using pretty_print? i would like to do
something like

raise SomeError, “object was <#{ object.pretty_print_inspect }>”

but that obviously does not work.

what i am after is a method on object, or that takes an object, which returns
as a string the output that pp(object) would have produced. i know i can do
PP.pp(obj, port) but am looking for something shorter…

-a

···

ATTN: please update your address books with address below!

===============================================================================

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
STP :: http://www.ngdc.noaa.gov/stp/
NGDC :: http://www.ngdc.noaa.gov/
NESDIS :: http://www.nesdis.noaa.gov/
NOAA :: http://www.noaa.gov/
US DOC :: http://www.commerce.gov/

The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”

/bin/sh -c ‘for l in ruby perl;do $l -e “print “\x3a\x2d\x29\x0a””;done’
===============================================================================


(Thomas Adam) #2

— “Ara.T.Howard” Ara.T.Howard@noaa.gov wrote:

Could your signature please be elided from this list… it basically
accounts for 25% of your over all mail.

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
"TAG Editor" – http://linuxgazette.net

" We’ll just save up your sins, Thomas, and punish
you for all of them at once when you get better. The
experience will probably kill you. :)"

– Benjamin A. Okopnik (Linux Gazette Technical Editor)


BT Yahoo! Broadband - Free modem offer, sign up online today and save £80 http://btyahoo.yahoo.co.uk


(Gavin Sinclair) #3

FWIW:

require ‘extensions/object’ # from Rubyforge

x = some_object.pp_s

Not a great name, perhaps; I just picked it up somewhere and liked the
idea.

Gavin

···

On Friday, February 13, 2004, 3:05:01 AM, Ara.T.Howard wrote:

what i am after is a method on object, or that takes an object, which returns
as a string the output that pp(object) would have produced. i know i can do
PP.pp(obj, port) but am looking for something shorter…


(Harpo) #4

I do like your sense of humour, your reply is only 20% of your signature.

For people who like a long signature, they can put it in an page on a web
site and give the URL in their signature.

···

On Fri, 13 Feb 2004 01:10:02 +0900, Thomas Adam wrote:

— “Ara.T.Howard” Ara.T.Howard@noaa.gov wrote:

Could your signature please be elided from this list… it basically
accounts for 25% of your over all mail.


Harpo : my signature is only 6 bytes length ! But I already planned to put
it on an html page on the web to reduce bandwhith use.