File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 61
61
# Tanaka Akira <akr@fsij.org>
62
62
63
63
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.
64
74
def PP . width_for ( out )
65
75
begin
66
76
require 'io/console'
@@ -74,7 +84,8 @@ def PP.width_for(out)
74
84
# +width+ columns in width.
75
85
#
76
86
# 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).
78
89
#
79
90
# PP.pp returns +out+.
80
91
def PP . pp ( obj , out = $>, width = width_for ( out ) )
You can’t perform that action at this time.
0 commit comments