Project

General

Profile

Feature #12913 ยป pp-default-maxwidth.patch

mame (Yusuke Endoh), 11/09/2016 02:59 PM

View differences:

lib/pp.rb
89 89
# Tanaka Akira <akr@fsij.org>
90 90

  
91 91
class PP < PrettyPrint
92
  # Sets the default maximum width of a line.
93
  # This defaults to 79, and should be a Fixnum.
94
  #
95
  # Note that this settings is only for PP; it does not affect the default
96
  # setting of PrettyPrint class.
97
  def PP.default_maxwidth=(width)
98
    @@default_maxwidth = width
99
  end
100

  
101
  # Gets the default maximum width of a line.
102
  def PP.default_maxwidth
103
    @@default_maxwidth
104
  end
105

  
92 106
  # Outputs +obj+ to +out+ in pretty printed format of
93 107
  # +width+ columns in width.
94 108
  #
95 109
  # If +out+ is omitted, <code>$></code> is assumed.
96
  # If +width+ is omitted, 79 is assumed.
110
  # If +width+ is omitted, the value of <code>PP.default_maxwidth</code>
111
  # is used by default.
97 112
  #
98 113
  # PP.pp returns +out+.
99
  def PP.pp(obj, out=$>, width=79)
114
  def PP.pp(obj, out=$>, width=@@default_maxwidth)
100 115
    q = PP.new(out, width)
101 116
    q.guard_inspect_key {q.pp obj}
102 117
    q.flush