From bdde51172cbf2754f6bbaa9e1678fbcc3d689dba Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 18 Sep 2009 15:42:59 +0000 Subject: * string.c: added rdocs for symbol. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/string.c b/string.c index dbf14f8ac3..1d15f9a6e8 100644 --- a/string.c +++ b/string.c @@ -7334,12 +7334,28 @@ sym_to_proc(VALUE sym) } } +/* + * call-seq: + * + * sym.succ + * + * Same as sym.to_s.succ.intern. + */ + static VALUE sym_succ(VALUE sym) { return rb_str_intern(rb_str_succ(rb_sym_to_s(sym))); } +/* + * call-seq: + * + * str <=> other => -1, 0, +1 + * + * Compares _sym_ with _other_ in string form. + */ + static VALUE sym_cmp(VALUE sym, VALUE other) { @@ -7349,6 +7365,14 @@ sym_cmp(VALUE sym, VALUE other) return rb_str_cmp_m(rb_sym_to_s(sym), rb_sym_to_s(other)); } +/* + * call-seq: + * + * sym.casecmp(other) => -1, 0, +1 + * + * Case-insensitive version of Symbol#<=>. + */ + static VALUE sym_casecmp(VALUE sym, VALUE other) { @@ -7358,54 +7382,118 @@ sym_casecmp(VALUE sym, VALUE other) return rb_str_casecmp(rb_sym_to_s(sym), rb_sym_to_s(other)); } +/* + * call-seq: + * sym =~ obj => fixnum or nil + * + * Returns sym.to_s =~ obj. + */ + static VALUE sym_match(VALUE sym, VALUE other) { return rb_str_match(rb_sym_to_s(sym), other); } +/* + * call-seq: + * sym[idx] => char + * sym[b, n] => char + * + * Returns sym.to_s[]. + */ + static VALUE sym_aref(int argc, VALUE *argv, VALUE sym) { return rb_str_aref_m(argc, argv, rb_sym_to_s(sym)); } +/* + * call-seq: + * sym.length => integer + * + * Same as sym.to_s.length. + */ + static VALUE sym_length(VALUE sym) { return rb_str_length(rb_id2str(SYM2ID(sym))); } +/* + * call-seq: + * sym.empty? => true or false + * + * Returns that _sym_ is :"" or not. + */ + static VALUE sym_empty(VALUE sym) { return rb_str_empty(rb_id2str(SYM2ID(sym))); } +/* + * call-seq: + * sym.upcase => symbol + * + * Same as sym.to_s.upcase.intern. + */ + static VALUE sym_upcase(VALUE sym) { return rb_str_intern(rb_str_upcase(rb_id2str(SYM2ID(sym)))); } +/* + * call-seq: + * sym.downcase => symbol + * + * Same as sym.to_s.downcase.intern. + */ + static VALUE sym_downcase(VALUE sym) { return rb_str_intern(rb_str_downcase(rb_id2str(SYM2ID(sym)))); } +/* + * call-seq: + * sym.capitalize => symbol + * + * Same as sym.to_s.capitalize.intern. + */ + static VALUE sym_capitalize(VALUE sym) { return rb_str_intern(rb_str_capitalize(rb_id2str(SYM2ID(sym)))); } +/* + * call-seq: + * sym.swapcase => symbol + * + * Same as sym.to_s.swapcase.intern. + */ + static VALUE sym_swapcase(VALUE sym) { return rb_str_intern(rb_str_swapcase(rb_id2str(SYM2ID(sym)))); } +/* + * call-seq: + * sym.encoding => encoding + * + * Returns the Encoding object that represents the encoding of _sym_. + */ + static VALUE sym_encoding(VALUE sym) { -- cgit v1.2.3