ruby-changes:20092
From: drbrain <ko1@a...>
Date: Fri, 17 Jun 2011 07:38:54 +0900 (JST)
Subject: [ruby-changes:20092] drbrain:r32139 (trunk): * lib/prettyprint.rb: Improve documentation. Patch by Ysiad
drbrain 2011-06-17 07:38:48 +0900 (Fri, 17 Jun 2011) New Revision: 32139 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32139 Log: * lib/prettyprint.rb: Improve documentation. Patch by Ysiad Ferreiras. [#4834] Modified files: trunk/ChangeLog trunk/lib/prettyprint.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 32138) +++ ChangeLog (revision 32139) @@ -1,3 +1,8 @@ +Fri Jun 17 07:38:31 2011 Eric Hodel <drbrain@s...> + + * lib/prettyprint.rb: Improve documentation. Patch by Ysiad + Ferreiras. [#4834] + Fri Jun 17 07:23:03 2011 Eric Hodel <drbrain@s...> * array.c (rb_ary_drop): Improve documentation. Patch by Caley Woods. Index: lib/prettyprint.rb =================================================================== --- lib/prettyprint.rb (revision 32138) +++ lib/prettyprint.rb (revision 32139) @@ -93,6 +93,7 @@ attr_reader :output, :maxwidth, :newline, :genspace attr_reader :indent, :group_queue + # Returns the group most recently added to the stack. def current_group @group_stack.last end @@ -119,6 +120,7 @@ current_group.first? end + # Breaks the buffer into lines that are shorter than #maxwidth def break_outmost_groups while @maxwidth < @output_width + @buffer_width return unless group = @group_queue.deq @@ -155,11 +157,20 @@ end end + # This is similar to #breakable, but is less-likely to insert a newline. + # + # The text sep+ is inserted if a line is not broken at this point. + # + # If +sep+ is not specified, " " is used. + # + # If +width+ is not specified, +sep.length+ is used. You will have to + # specify this when +sep+ is a multibyte character, for example. + # def fill_breakable(sep=' ', width=sep.length) group { breakable sep, width } end - # This tells "you can break a line here if necessary", and a +width+\-column + # This says "you can break a line here if necessary", and a +width+\-column # text +sep+ is inserted if a line is not broken at the point. # # If +sep+ is not specified, " " is used. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/