pp equiv of #inspect

A

Ara.T.Howard

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'
===============================================================================
 
G

Gavin Sinclair

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...

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,131
Latest member
IsiahLiebe
Top