Skip to content

Commit cad3cc7

Browse files
committed
[DOC] Update for PP.width_for [Feature #12913]
1 parent 226c50c commit cad3cc7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/pp.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
# Tanaka Akira <akr@fsij.org>
6262

6363
class PP < PrettyPrint
64+
# Returns the usable width for +out+.
65+
# As the width of +out+:
66+
# 1. If +out+ is assigned to a tty device, its width is used.
67+
# 2. Otherwise, or it could not get the value, the +COLUMN+
68+
# environment variable is assumed to be set to the width.
69+
# 3. If +COLUMN+ is not set to a non-zero number, 80 is assumed.
70+
#
71+
# And finally, returns the above width value - 1.
72+
# * This -1 is for Windows command prompt, which moves the cursor to
73+
# the next line if it reaches the last column.
6474
def PP.width_for(out)
6575
begin
6676
require 'io/console'
@@ -74,7 +84,8 @@ def PP.width_for(out)
7484
# +width+ columns in width.
7585
#
7686
# If +out+ is omitted, <code>$></code> is assumed.
77-
# If +width+ is omitted, 79 is assumed.
87+
# If +width+ is omitted, the width of +out+ is assumed (see
88+
# width_for).
7889
#
7990
# PP.pp returns +out+.
8091
def PP.pp(obj, out=$>, width=width_for(out))

0 commit comments

Comments
 (0)