[#3228] Core support for Gems, and namespace — "Luke A. Kanies" <luke@...>

Hi all,

21 messages 2004/07/27
[#3230] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Tue, 27 Jul 2004 11:39:08 +0900, Luke A. Kanies <luke@madstop.com> wrote:

[#3234] Re: Core support for Gems, and namespace — "Luke A. Kanies" <luke@...> 2004/07/27

On Tue, 27 Jul 2004, Austin Ziegler wrote:

[#3238] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Wed, 28 Jul 2004 00:14:29 +0900, Luke A. Kanies <luke@madstop.com> wrote:

Documentation fix for String#ljust rjust center

From: Michael Neumann <mneumann@...>
Date: 2004-07-16 10:09:56 UTC
List: ruby-core #3192
The pad string argument of these methods is undocumented.

patch appended! feel free to improve the documentation.

hmm, maybe the argument "integer" could be renamed to "width"?

BTW, it would be nice if rdoc could generate test cases for the examples 
(maybe if there's a "#=>" at the end of the line?).


Regards,

   Michael

Attachments (1)

string.diff (2.52 KB, text/x-diff)
Index: string.c
===================================================================
RCS file: /src/ruby/string.c,v
retrieving revision 1.193
diff -u -r1.193 string.c
--- string.c	5 Jun 2004 02:30:41 -0000	1.193
+++ string.c	16 Jul 2004 10:06:11 -0000
@@ -4460,14 +4460,16 @@
 
 /*
  *  call-seq:
- *     str.ljust(integer)   => new_str
+ *     str.ljust(integer, pad=" ")   => new_str
  *  
  *  If <i>integer</i> is greater than the length of <i>str</i>, returns a new
  *  <code>String</code> of length <i>integer</i> with <i>str</i> left justified
- *  and space padded; otherwise, returns <i>str</i>.
+ *  and padded with string <i>pad</i>; otherwise, returns <i>str</i>.
  *     
- *     "hello".ljust(4)    #=> "hello"
- *     "hello".ljust(20)   #=> "hello               "
+ *     "hello".ljust(4)         #=> "hello"
+ *     "hello".ljust(20)        #=> "hello               "
+ *     "hello".ljust(20, "*")   #=> "hello***************"
+ *     "hello".ljust(20, "le")  #=> "hellolelelelelelelel"
  */
 
 static VALUE
@@ -4482,14 +4484,16 @@
 
 /*
  *  call-seq:
- *     str.rjust(integer)   => new_str
+ *     str.rjust(integer, pad=" ")   => new_str
  *  
  *  If <i>integer</i> is greater than the length of <i>str</i>, returns a new
  *  <code>String</code> of length <i>integer</i> with <i>str</i> right justified
- *  and space padded; otherwise, returns <i>str</i>.
+ *  and padded with string <i>pad</i>; otherwise, returns <i>str</i>.
  *     
- *     "hello".rjust(4)    #=> "hello"
- *     "hello".rjust(20)   #=> "               hello"
+ *     "hello".rjust(4)         #=> "hello"
+ *     "hello".rjust(20)        #=> "               hello"
+ *     "hello".ljust(20, "*")   #=> "***************hello"
+ *     "hello".ljust(20, "le")  #=> "lelelelelelelelhello"
  */
 
 static VALUE
@@ -4504,14 +4508,17 @@
 
 /*
  *  call-seq:
- *     str.center(integer)   => new_str
+ *     str.center(integer, pad=" ")   => new_str
  *  
  *  If <i>integer</i> is greater than the length of <i>str</i>, returns a new
  *  <code>String</code> of length <i>integer</i> with <i>str</i> centered
- *  between spaces; otherwise, returns <i>str</i>.
+ *  between <i>pad</i> (spaces by default); otherwise, returns <i>str</i>.
  *     
- *     "hello".center(4)    #=> "hello"
- *     "hello".center(20)   #=> "       hello        "
+ *     "hello".center(4)         #=> "hello"
+ *     "hello".center(20)        #=> "       hello        "
+ *     "hello".center(20, "*")   #=> "*******hello********"
+ *     "hello".center(20, "12")  #=> "1212121hello12121212"
+
  */
 
 static VALUE

In This Thread

Prev Next