summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-03-24 19:40:58 -0500
committerGitHub <noreply@github.com>2022-03-24 19:40:58 -0500
commit465edb96f08e9405b861559c3f7cea3691be5a77 (patch)
tree588562a361826a23d6ff5c9e9500e6adf93d2bb6 /string.c
parent343ea9967e4a6b279eed6bd8e81ad0bdc747f254 (diff)
downloadruby-465edb96f08e9405b861559c3f7cea3691be5a77.tar.gz
[DOC] Enhanced RDoc for String (#5707)
Treated: #chomp #chomp! #chop #chop!
Diffstat (limited to 'string.c')
-rw-r--r--string.c53
1 files changed, 15 insertions, 38 deletions
diff --git a/string.c b/string.c
index f40d850d5a..9d200ecb20 100644
--- a/string.c
+++ b/string.c
@@ -9452,11 +9452,12 @@ chopped_length(VALUE str)
/*
* call-seq:
- * str.chop! -> str or nil
+ * chop! -> self or nil
*
- * Processes <i>str</i> as for String#chop, returning <i>str</i>, or
- * <code>nil</code> if <i>str</i> is the empty string. See also
- * String#chomp!.
+ * Like String#chop, but modifies +self+ in place;
+ * returns +nil+ if +self+ is empty, +self+ otherwise.
+ *
+ * Related: String#chomp!.
*/
static VALUE
@@ -9479,20 +9480,10 @@ rb_str_chop_bang(VALUE str)
/*
* call-seq:
- * str.chop -> new_str
+ * chop -> new_string
*
- * Returns a new String with the last character removed. If the
- * string ends with <code>\r\n</code>, both characters are
- * removed. Applying <code>chop</code> to an empty string returns an
- * empty string. String#chomp is often a safer alternative, as it
- * leaves the string unchanged if it doesn't end in a record
- * separator.
+ * :include: doc/string/chop.rdoc
*
- * "string\r\n".chop #=> "string"
- * "string\n\r".chop #=> "string\n"
- * "string\n".chop #=> "string"
- * "string".chop #=> "strin"
- * "x".chop.chop #=> ""
*/
static VALUE
@@ -9641,11 +9632,11 @@ rb_str_chomp_string(VALUE str, VALUE rs)
/*
* call-seq:
- * str.chomp!(separator=$/) -> str or nil
+ * chomp!(line_sep = $/) -> self or nil
+ *
+ * Like String#chomp, but modifies +self+ in place;
+ * returns +nil+ if no modification made, +self+ otherwise.
*
- * Modifies <i>str</i> in place as described for String#chomp,
- * returning <i>str</i>, or <code>nil</code> if no modifications were
- * made.
*/
static VALUE
@@ -9662,24 +9653,10 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
/*
* call-seq:
- * str.chomp(separator=$/) -> new_str
- *
- * Returns a new String with the given record separator removed
- * from the end of <i>str</i> (if present). If <code>$/</code> has not been
- * changed from the default Ruby record separator, then <code>chomp</code> also
- * removes carriage return characters (that is, it will remove <code>\n</code>,
- * <code>\r</code>, and <code>\r\n</code>). If <code>$/</code> is an empty string,
- * it will remove all trailing newlines from the string.
- *
- * "hello".chomp #=> "hello"
- * "hello\n".chomp #=> "hello"
- * "hello\r\n".chomp #=> "hello"
- * "hello\n\r".chomp #=> "hello\n"
- * "hello\r".chomp #=> "hello"
- * "hello \n there".chomp #=> "hello \n there"
- * "hello".chomp("llo") #=> "he"
- * "hello\r\n\r\n".chomp('') #=> "hello"
- * "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r"
+ * chomp(line_sep = $/) -> new_string
+ *
+ * :include: doc/string/chomp.rdoc
+ *
*/
static VALUE