D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Symbol
/
Filename :
cdesc-Symbol.ri
back
Copy
U:RDoc::NormalClass[iI"Symbol:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[ : @fileI"$ext/json/lib/json/add/symbol.rb;T:0@omit_headings_from_table_of_contents_below0o;;[#o:RDoc::Markup::Paragraph;[I"QA +Symbol+ object represents a named identifier inside the Ruby interpreter.;To:RDoc::Markup::BlankLine o;;[I"6You can create a +Symbol+ object explicitly with:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o;;[I"GA {symbol literal}[rdoc-ref:syntax/literals.rdoc@Symbol+Literals].;T@o;;[I"&The same +Symbol+ object will be ;TI"Hcreated for a given name or string for the duration of a program's ;TI"Hexecution, regardless of the context or meaning of that name. Thus ;TI"Dif <code>Fred</code> is a constant in one context, a method in ;TI"Fanother, and a class in a third, the +Symbol+ <code>:Fred</code> ;TI"3will be the same object in all three contexts.;T@o:RDoc::Markup::Verbatim;[I"module One ;TI" class Fred ;TI" end ;TI" $f1 = :Fred ;TI" end ;TI"module Two ;TI" Fred = 1 ;TI" $f2 = :Fred ;TI" end ;TI"def Fred() ;TI" end ;TI"$f3 = :Fred ;TI"!$f1.object_id #=> 2514190 ;TI"!$f2.object_id #=> 2514190 ;TI"!$f3.object_id #=> 2514190 ;T:@format0o;;[I"BConstant, method, and variable names are returned as symbols:;T@o;;[I"module One ;TI" Two = 2 ;TI" def three; 3 end ;TI" @four = 4 ;TI" @@five = 5 ;TI" $six = 6 ;TI" end ;TI"seven = 7 ;TI" ;TI"One.constants ;TI"# => [:Two] ;TI" One.instance_methods(true) ;TI"# => [:three] ;TI"One.instance_variables ;TI"# => [:@four] ;TI"One.class_variables ;TI"# => [:@@five] ;TI""global_variables.grep(/six/) ;TI"# => [:$six] ;TI"local_variables ;TI"# => [:seven] ;T;0o;;[I"<A +Symbol+ object differs from a String object in that ;TI"Ga +Symbol+ object represents an identifier, while a String object ;TI"represents text or data.;T@S:RDoc::Markup::Heading: leveli: textI"What's Here;T@o;;[I".First, what's elsewhere. \Class +Symbol+:;T@o; ;;;[o;;0;[o;;[I"AInherits from {class Object}[rdoc-ref:Object@What-27s+Here].;To;;0;[o;;[I"EIncludes {module Comparable}[rdoc-ref:Comparable@What-27s+Here].;T@o;;[I"?Here, class +Symbol+ provides methods that are useful for:;T@o; ;;;[o;;0;[o;;[I"5{Querying}[rdoc-ref:Symbol@Methods+for+Querying];To;;0;[o;;[I"7{Comparing}[rdoc-ref:Symbol@Methods+for+Comparing];To;;0;[o;;[I"9{Converting}[rdoc-ref:Symbol@Methods+for+Converting];T@S;;i;I"Methods for Querying;T@o; ;;;[o;;0;[o;;[I"U::all_symbols: Returns an array of the symbols currently in Ruby's symbol table.;To;;0;[o;;[I"L#=~: Returns the index of the first substring in symbol that matches a ;TI"Fgiven Regexp or other object; returns +nil+ if no match is found.;To;;0;[o;;[I"1#[], #slice : Returns a substring of symbol ;TI"Ddetermined by a given index, start/length, or range, or string.;To;;0;[o;;[I"I#empty?: Returns +true+ if +self.length+ is zero; +false+ otherwise.;To;;0;[o;;[I"I#encoding: Returns the Encoding object that represents the encoding ;TI"of symbol.;To;;0;[o;;[I"4#end_with?: Returns +true+ if symbol ends with ;TI"any of the given strings.;To;;0;[o;;[I"2#match: Returns a MatchData object if symbol ;TI"-matches a given Regexp; +nil+ otherwise.;To;;0;[o;;[I"'#match?: Returns +true+ if symbol ;TI"/matches a given Regexp; +false+ otherwise.;To;;0;[o;;[I"@#length, #size: Returns the number of characters in symbol.;To;;0;[o;;[I"8#start_with?: Returns +true+ if symbol starts with ;TI"any of the given strings.;T@S;;i;I"Methods for Comparing;T@o; ;;;[ o;;0;[o;;[I"L#<=>: Returns -1, 0, or 1 as a given symbol is smaller than, equal to, ;TI"or larger than symbol.;To;;0;[o;;[I"J#==, #===: Returns +true+ if a given symbol has the same content and ;TI"encoding.;To;;0;[o;;[I"=#casecmp: Ignoring case, returns -1, 0, or 1 as a given ;TI"=symbol is smaller than, equal to, or larger than symbol.;To;;0;[o;;[I"D#casecmp?: Returns +true+ if symbol is equal to a given symbol ;TI"3after Unicode case folding; +false+ otherwise.;T@S;;i;I"Methods for Converting;T@o; ;;;[o;;0;[o;;[I"B#capitalize: Returns symbol with the first character upcased ;TI"(and all other characters downcased.;To;;0;[o;;[I"=#downcase: Returns symbol with all characters downcased.;To;;0;[o;;[I"O#inspect: Returns the string representation of +self+ as a symbol literal.;To;;0;[o;;[I">#name: Returns the frozen string corresponding to symbol.;To;;0;[o;;[I"F#succ, #next: Returns the symbol that is the successor to symbol.;To;;0;[o;;[I"D#swapcase: Returns symbol with all upcase characters downcased ;TI")and all downcase characters upcased.;To;;0;[o;;[I"R#to_proc: Returns a Proc object which responds to the method named by symbol.;To;;0;[o;;[I"A#to_s, #id2name: Returns the string corresponding to +self+.;To;;0;[o;;[I"&#to_sym, #intern: Returns +self+.;To;;0;[o;;[I"9#upcase: Returns symbol with all characters upcased.;T; I" string.c;T; 0o;;[ ; I"symbol.rb;T; 0; 0; 0[ [ [[I"Comparable;To;;[ ; @; 0I" string.c;T[[I" class;T[[:public[[I"all_symbols;T@[I"json_create;TI"$ext/json/lib/json/add/symbol.rb;T[:protected[ [:private[ [I" instance;T[[;[$[I"<=>;T@[I"==;T@[I"===;T@[I"=~;T@[I"[];T@[I"as_json;T@[I"capitalize;T@[I"casecmp;T@[I" casecmp?;T@[I" downcase;T@[I"empty?;T@[I" encoding;T@[I"end_with?;T@[I"id2name;TI"symbol.rb;T[I"inspect;T@[I"intern;T@C[I"length;T@[I" match;T@[I"match?;T@[I" name;T@C[I" next;T@[I" size;T@[I" slice;T@[I"start_with?;T@[I" succ;T@[I" swapcase;T@[I"to_json;T@[I"to_proc;T@[I" to_s;T@C[I"to_sym;T@C[I"upcase;T@[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0; 0[@ @@ @ cRDoc::TopLevel