R
Ronald Fischer
I like the formatting one gets by
require 'pp'
pp foo() # etc.
In my application however, I don't want the pp-formatted string to be
printed, but to be returned as a string to my application. Searching
the Net, I came up with the following solution (Example):
require 'pp'
....
result=3Dfoo(bar)
$my_message=3D"The function call foo("+
bar.pretty_print_inspect+
") returned: "+result.pretty_print_inspect
This works well most of the time, for example if the values formatted
with pretty_print_inspect are arrays or numbers. I get, however, a
runtime error when calling for String:
"abc".pretty_print_inspect
RuntimeError: pretty_print is not overridden for String
Is there a different way to use the module pp, so that its output goes=20
to a string?
Ronald
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
=20
require 'pp'
pp foo() # etc.
In my application however, I don't want the pp-formatted string to be
printed, but to be returned as a string to my application. Searching
the Net, I came up with the following solution (Example):
require 'pp'
....
result=3Dfoo(bar)
$my_message=3D"The function call foo("+
bar.pretty_print_inspect+
") returned: "+result.pretty_print_inspect
This works well most of the time, for example if the values formatted
with pretty_print_inspect are arrays or numbers. I get, however, a
runtime error when calling for String:
"abc".pretty_print_inspect
RuntimeError: pretty_print is not overridden for String
Is there a different way to use the module pp, so that its output goes=20
to a string?
Ronald
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
=20