Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

PP.width_for

width_for(out)

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.

See also .singleline_pp .sharing_detection= also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1