summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-04-13 13:45:18 -0500
committerGitHub <noreply@github.com>2022-04-13 13:45:18 -0500
commitdfdc03248fc01a84577e5a6094acbcaa41460144 (patch)
treee4d253998974aa1fcc7e1eedeb6aef3bbc65d1f0 /string.c
parentfde79524894cbb2f0a517a9c6d70e4d7816f8b22 (diff)
[DOC] Enhanced RDoc for Symbol (#5796)
Treats: #[] #length #empty? #upcase #downcase #capitalize #swapcase #start_with? #end_with? #encoding ::all_symbols
Notes
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'string.c')
-rw-r--r--string.c72
1 files changed, 31 insertions, 41 deletions
diff --git a/string.c b/string.c
index 938edd9cdf..fe82f7af13 100644
--- a/string.c
+++ b/string.c
@@ -11627,13 +11627,15 @@ sym_match_m_p(int argc, VALUE *argv, VALUE sym)
}
/*
- * call-seq:
- * sym[idx] -> char
- * sym[b, n] -> string
- * sym.slice(idx) -> char
- * sym.slice(b, n) -> string
+ * call-seq:
+ * symbol[index] -> string or nil
+ * symbol[start, length] -> string or nil
+ * symbol[range] -> string or nil
+ * symbol[regexp, capture = 0] -> string or nil
+ * symbol[substring] -> string or nil
+ *
+ * Equivalent to <tt>symbol.to_s[]</tt>; see String#[].
*
- * Returns <code>sym.to_s[]</code>.
*/
static VALUE
@@ -11643,11 +11645,13 @@ sym_aref(int argc, VALUE *argv, VALUE sym)
}
/*
- * call-seq:
- * sym.length -> integer
- * sym.size -> integer
+ * call-seq:
+ * length -> integer
+ *
+ * Equivalent to <tt>self.to_s.length</tt>; see String#length.
+ *
+ * Symbol#size is an alias for Symbol#length.
*
- * Same as <code>sym.to_s.length</code>.
*/
static VALUE
@@ -11657,10 +11661,11 @@ sym_length(VALUE sym)
}
/*
- * call-seq:
- * sym.empty? -> true or false
+ * call-seq:
+ * empty? -> true or false
+ *
+ * Returns +true+ if +self+ is <tt>:''</tt>, +false+ otherwise.
*
- * Returns whether _sym_ is :"" or not.
*/
static VALUE
@@ -11737,17 +11742,10 @@ sym_swapcase(int argc, VALUE *argv, VALUE sym)
/*
* call-seq:
- * sym.start_with?([prefixes]+) -> true or false
- *
- * Returns true if +sym+ starts with one of the +prefixes+ given.
- * Each of the +prefixes+ should be a String or a Regexp.
+ * start_with?(*string_or_regexp) -> true or false
*
- * :hello.start_with?("hell") #=> true
- * :hello.start_with?(/H/i) #=> true
+ * Equivalent to <tt>self.to_s.start_with?</tt>; see String#start_with?.
*
- * # returns true if one of the prefixes matches.
- * :hello.start_with?("heaven", "hell") #=> true
- * :hello.start_with?("heaven", "paradise") #=> false
*/
static VALUE
@@ -11758,15 +11756,11 @@ sym_start_with(int argc, VALUE *argv, VALUE sym)
/*
* call-seq:
- * sym.end_with?([suffixes]+) -> true or false
+ * end_with?(*string_or_regexp) -> true or false
*
- * Returns true if +sym+ ends with one of the +suffixes+ given.
*
- * :hello.end_with?("ello") #=> true
+ * Equivalent to <tt>self.to_s.end_with?</tt>; see String#end_with?.
*
- * # returns true if one of the +suffixes+ matches.
- * :hello.end_with?("heaven", "ello") #=> true
- * :hello.end_with?("heaven", "paradise") #=> false
*/
static VALUE
@@ -11776,10 +11770,11 @@ sym_end_with(int argc, VALUE *argv, VALUE sym)
}
/*
- * call-seq:
- * sym.encoding -> encoding
+ * call-seq:
+ * encoding -> encoding
+ *
+ * Equivalent to <tt>self.to_s.encoding</tt>; see String#encoding.
*
- * Returns the Encoding object that represents the encoding of _sym_.
*/
static VALUE
@@ -11824,18 +11819,13 @@ rb_to_symbol(VALUE name)
/*
* call-seq:
- * Symbol.all_symbols => array
+ * Symbol.all_symbols -> array_of_symbols
+ *
+ * Returns an array of all symbols currently in Ruby's symbol table:
*
- * Returns an array of all the symbols currently in Ruby's symbol
- * table.
+ * Symbol.all_symbols.size # => 9334
+ * Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"]
*
- * Symbol.all_symbols.size #=> 903
- * Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
- * :chown, :EOFError, :$;, :String,
- * :LOCK_SH, :"setuid?", :$<,
- * :default_proc, :compact, :extend,
- * :Tms, :getwd, :$=, :ThreadGroup,
- * :wait2, :$>]
*/
static VALUE