summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-05 20:39:15 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-05 20:39:15 +0000
commit9360721e5880fdeff4e72495991b3ffc8d94b190 (patch)
tree0fc6800d22bb1ab81670897dff5b66c0ec2beb53 /string.c
parent6b5a88a36dbd320466e4dcfb859a9ef4a6248e1d (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/string.c b/string.c
index e275e577ea..c49a1b11dc 100644
--- a/string.c
+++ b/string.c
@@ -1147,7 +1147,10 @@ rb_str_length(VALUE str)
* 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 @@ rb_str_bytesize(VALUE str)
* Returns <code>true</code> if <i>str</i> has a length of zero.
*
* "hello".empty? #=> false
+ * " ".empty? #=> false
* "".empty? #=> true
*/
@@ -1209,10 +1213,11 @@ rb_str_plus(VALUE str1, VALUE str2)
* 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 @@ rb_str_inspect(VALUE str)
* 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 @@ rb_str_rjust(int argc, VALUE *argv, VALUE str)
/*
* 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 "