Comment on this RCR (edit wiki page) | RCRchive home

RCR 215: Object#pretty

submitted by ahoward on Fri Feb 13 2004 08:40:53 AM -0800

Status: pending


Abstract

make pretty_printing more available and easier to use

Problem

Proposal

creation of Object#pretty method which is analogous to Object#inspect, only returning result of 'pp' instead of the result from 'p'

Analysis

simply add a method

Implementation

class Object
def pretty s = ''
autoload :PP, 'pp'
PP::pp self, s
s
end
end

Vote for this RCR

Strongly opposed [1]
Opposed [4]
Neutral [0]
In favor [0]
Strongly advocate [0]

Change the status of this RCR to:

accepted

rejected

withdrawn


This isn't needed, really.

  s = [].methods
  require 'pp'
  s.methods - s
  s.pretty_print_inspect


Since PP.pp(obj, out) returns out,

  s = ''
  PP::pp very_large_hash, s
  raise ArgumentError, s

can be described as:

  raise ArgumentError, PP::pp(very_large_hash, '')

Note that pretty_print_inspect doesn't solve the problem because it is designed to use as inspect using pretty_print.


Back to RCRchive.


RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog