Feature #12913 ยป pp-default-maxwidth.patch
lib/pp.rb | ||
---|---|---|
# Tanaka Akira <akr@fsij.org>
|
||
class PP < PrettyPrint
|
||
# Sets the default maximum width of a line.
|
||
# This defaults to 79, and should be a Fixnum.
|
||
#
|
||
# Note that this settings is only for PP; it does not affect the default
|
||
# setting of PrettyPrint class.
|
||
def PP.default_maxwidth=(width)
|
||
@@default_maxwidth = width
|
||
end
|
||
# Gets the default maximum width of a line.
|
||
def PP.default_maxwidth
|
||
@@default_maxwidth
|
||
end
|
||
# Outputs +obj+ to +out+ in pretty printed format of
|
||
# +width+ columns in width.
|
||
#
|
||
# If +out+ is omitted, <code>$></code> is assumed.
|
||
# If +width+ is omitted, 79 is assumed.
|
||
# If +width+ is omitted, the value of <code>PP.default_maxwidth</code>
|
||
# is used by default.
|
||
#
|
||
# PP.pp returns +out+.
|
||
def PP.pp(obj, out=$>, width=79)
|
||
def PP.pp(obj, out=$>, width=@@default_maxwidth)
|
||
q = PP.new(out, width)
|
||
q.guard_inspect_key {q.pp obj}
|
||
q.flush
|