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

ruby-changes:24276

From: drbrain <ko1@a...>
Date: Fri, 6 Jul 2012 05:39:27 +0900 (JST)
Subject: [ruby-changes:24276] drbrain:r36327 (trunk): * string.c (rb_str_bytesize): Improve documentation. Patch by Oscar

drbrain	2012-07-06 05:39:15 +0900 (Fri, 06 Jul 2012)

  New Revision: 36327

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36327

  Log:
    * string.c (rb_str_bytesize):  Improve documentation.  Patch by Oscar
      Del Ben from github issue #138.
    * string.c (rb_str_empty):  ditto.
    * string.c (rb_str_times):  ditto.
    * string.c (rb_str_dump):  ditto.
    * string.c (rb_str_center):  ditto.

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36326)
+++ ChangeLog	(revision 36327)
@@ -1,3 +1,12 @@
+Fri Jul  6 05:38:44 2012  Eric Hodel  <drbrain@s...>
+
+	* string.c (rb_str_bytesize):  Improve documentation.  Patch by Oscar
+	  Del Ben from github issue #138.
+	* string.c (rb_str_empty):  ditto.
+	* string.c (rb_str_times):  ditto.
+	* string.c (rb_str_dump):  ditto.
+	* string.c (rb_str_center):  ditto.
+
 Fri Jul  6 04:05:59 2012  Eric Hodel  <drbrain@s...>
 
 	* ext/zlib/zlib.c (zstream_expand_buffer_without_gvl):  Use
Index: string.c
===================================================================
--- string.c	(revision 36326)
+++ string.c	(revision 36327)
@@ -1147,7 +1147,10 @@
  *  call-seq:
  *     str.bytesize  -> integer
  *
- *  Returns the length of <i>str</i> in bytes.
+ *  Returns the length of +str+ in bytes.
+ *
+ *    "\x80\u3042".bytesize  #=> 4
+ *    "hello".bytesize       #=> 5
  */
 
 static VALUE
@@ -1163,6 +1166,7 @@
  *  Returns <code>true</code> if <i>str</i> has a length of zero.
  *
  *     "hello".empty?   #=> false
+ *     " ".empty?       #=> false
  *     "".empty?        #=> true
  */
 
@@ -1209,10 +1213,11 @@
  *  call-seq:
  *     str * integer   -> new_str
  *
- *  Copy---Returns a new <code>String</code> containing <i>integer</i> copies of
- *  the receiver.
+ *  Copy --- Returns a new String containing +integer+ copies of the receiver.
+ *  +integer+ must be greater than or equal to 0.
  *
  *     "Ho! " * 3   #=> "Ho! Ho! Ho! "
+ *     "Ho! " * 0   #=> ""
  */
 
 VALUE
@@ -4532,8 +4537,10 @@
  *  call-seq:
  *     str.dump   -> new_str
  *
- *  Produces a version of <i>str</i> with all nonprinting characters replaced by
+ *  Produces a version of +str+ with all non-printing characters replaced by
  *  <code>\nnn</code> notation and all special characters escaped.
+ *
+ *    "hello \n ''".dump  #=> "\"hello \\n ''\"
  */
 
 VALUE
@@ -7126,11 +7133,11 @@
 
 /*
  *  call-seq:
- *     str.center(integer, padstr)   -> new_str
+ *     str.center(width, padstr=' ')   -> 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 and
- *  padded with <i>padstr</i>; otherwise, returns <i>str</i>.
+ *  Centers +str+ in +width+.  If +width+ is greater than the length of +str+,
+ *  returns a new String of length +width+ with +str+ centered and padded with
+ *  +padstr+; otherwise, returns +str+.
  *
  *     "hello".center(4)         #=> "hello"
  *     "hello".center(20)        #=> "       hello        "

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

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