[前][次][番号順一覧][スレッド一覧]

ruby-changes:70453

From: Nobuyoshi <ko1@a...>
Date: Thu, 23 Dec 2021 18:03:16 +0900 (JST)
Subject: [ruby-changes:70453] c6cf19340a (master): [ruby/pp] [DOC] Update for PP.width_for [Feature #12913]

https://git.ruby-lang.org/ruby.git/commit/?id=c6cf19340a

From c6cf19340a116f21d71ecc218a2e8c31fe2f1d85 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 23 Dec 2021 16:09:02 +0900
Subject: [ruby/pp] [DOC] Update for PP.width_for [Feature #12913]

https://github.com/ruby/pp/commit/cad3cc762c
---
 lib/pp.rb | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/pp.rb b/lib/pp.rb
index dd16bea2220..f43356a3dfa 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -61,6 +61,16 @@ require 'prettyprint' https://github.com/ruby/ruby/blob/trunk/lib/pp.rb#L61
 # Tanaka Akira <akr@f...>
 
 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)
     begin
       require 'io/console'
@@ -74,7 +84,8 @@ class PP < PrettyPrint https://github.com/ruby/ruby/blob/trunk/lib/pp.rb#L84
   # +width+ columns in width.
   #
   # 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+.
   def PP.pp(obj, out=$>, width=width_for(out))
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]