Marcel Molina Jr.
7/19/2007 3:00:00 AM
On Thu, Jul 19, 2007 at 11:54:53AM +0900, Joel VanderWerf wrote:
>
> >pp foo # pretty prints foo to stdout
> >
> >But I want to print to a string, which I'll then be handling in rails.
>
> irb(main):009:0> [1,2,3].pretty_print_inspect
> => "[1, 2, 3]"
> irb(main):010:0> [1,2,3].pretty_inspect
> => "[1, 2, 3]\n"
There is also the quite awkward:
irb(main):003:0> PP.pp((1..30).to_a, s = '')
=> "[1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19,\n 20,\n 21,\n 22,\n 23,\n 24,\n 25,\n 26,\n 27,\n 28,\n 29,\n 30]\n"
irb(main):004:0> s
=> "[1,\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19,\n 20,\n 21,\n 22,\n 23,\n 24,\n 25,\n 26,\n 27,\n 28,\n 29,\n 30]\n"
marcel
--
Marcel Molina Jr. <marcel@vernix.org>