[ruby/pp] [DOC] Update for PP.width_for [Feature #12913]
https://github.com/ruby/pp/commit/cad3cc762c
This commit is contained in:
parent
2da53b1468
commit
c6cf19340a
13
lib/pp.rb
13
lib/pp.rb
@ -61,6 +61,16 @@ require 'prettyprint'
|
|||||||
# Tanaka Akira <akr@fsij.org>
|
# Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
class PP < PrettyPrint
|
class PP < PrettyPrint
|
||||||
|
# Returns the usable width for +out+.
|
||||||
|
# As the width of +out+:
|
||||||
|
# 1. If +out+ is assigned to a tty device, its width is used.
|
||||||
|
# 2. Otherwise, or it could not get the value, the +COLUMN+
|
||||||
|
# environment variable is assumed to be set to the width.
|
||||||
|
# 3. If +COLUMN+ is not set to a non-zero number, 80 is assumed.
|
||||||
|
#
|
||||||
|
# And finally, returns the above width value - 1.
|
||||||
|
# * This -1 is for Windows command prompt, which moves the cursor to
|
||||||
|
# the next line if it reaches the last column.
|
||||||
def PP.width_for(out)
|
def PP.width_for(out)
|
||||||
begin
|
begin
|
||||||
require 'io/console'
|
require 'io/console'
|
||||||
@ -74,7 +84,8 @@ class PP < PrettyPrint
|
|||||||
# +width+ columns in width.
|
# +width+ columns in width.
|
||||||
#
|
#
|
||||||
# If +out+ is omitted, <code>$></code> is assumed.
|
# If +out+ is omitted, <code>$></code> is assumed.
|
||||||
# If +width+ is omitted, 79 is assumed.
|
# If +width+ is omitted, the width of +out+ is assumed (see
|
||||||
|
# width_for).
|
||||||
#
|
#
|
||||||
# PP.pp returns +out+.
|
# PP.pp returns +out+.
|
||||||
def PP.pp(obj, out=$>, width=width_for(out))
|
def PP.pp(obj, out=$>, width=width_for(out))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user