D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Class
/
Filename :
cdesc-Class.ri
back
Copy
U:RDoc::NormalClass[iI" Class:ET@I"Module;To:RDoc::Markup::Document:@parts[o;;[ : @fileI"class.c;T:0@omit_headings_from_table_of_contents_below0o;;[o:RDoc::Markup::Paragraph;[I";Extends any Class to include _json_creatable?_ method.;T; I" ext/json/lib/json/common.rb;T; 0o;;[o;;[I"FClasses in Ruby are first-class objects---each is an instance of ;TI"class Class.;To:RDoc::Markup::BlankLine o;;[I"0Typically, you create a new class by using:;T@o:RDoc::Markup::Verbatim;[I"class Name ;TI"0 # some code describing the class behavior ;TI" end ;T:@format0o;;[I"MWhen a new class is created, an object of type Class is initialized and ;TI"7assigned to a global constant (Name in this case).;T@o;;[I"FWhen <code>Name.new</code> is called to create a new object, the ;TI"-#new method in Class is run by default. ;TI":This can be demonstrated by overriding #new in Class:;T@o; ;[I"class Class ;TI" alias old_new new ;TI" def new(*args) ;TI"2 print "Creating a new ", self.name, "\n" ;TI" old_new(*args) ;TI" end ;TI" end ;TI" ;TI"class Name ;TI" end ;TI" ;TI"n = Name.new ;T;0o;;[I"<em>produces:</em>;T@o; ;[I"Creating a new Name ;T;0o;;[ I"DClasses, modules, and objects are interrelated. In the diagram ;TI"Fthat follows, the vertical arrows represent inheritance, and the ;TI"<parentheses metaclasses. All metaclasses are instances ;TI"of the class `Class'.;To; ;[I"< +---------+ +-... ;TI"8 | | | ;TI"< BasicObject-----|-->(BasicObject)-------|-... ;TI"8 ^ | ^ | ;TI"8 | | | | ;TI"< Object---------|----->(Object)---------|-... ;TI"8 ^ | ^ | ;TI"8 | | | | ;TI"8 +-------+ | +--------+ | ;TI"8 | | | | | | ;TI"< | Module-|---------|--->(Module)-|-... ;TI"8 | ^ | | ^ | ;TI"8 | | | | | | ;TI"< | Class-|---------|---->(Class)-|-... ;TI"8 | ^ | | ^ | ;TI"8 | +---+ | +----+ ;TI"* | | ;TI";obj--->OtherClass---------->(OtherClass)-----------...;T;0; I" object.c;T; 0; 0; 0[ [ [ [[I" class;T[[:public[[I"new;TI" object.c;T[:protected[ [:private[ [I" instance;T[[;[[I" allocate;T@f[I"attached_object;T@f[I"json_creatable?;TI" ext/json/lib/json/common.rb;T[I"new;T@f[I"subclasses;T@f[I"superclass;T@f[;[ [;[[I"inherited;T@f[ [U:RDoc::Context::Section[i 0o;;[ ; 0; 0[@ @@Z@ZcRDoc::TopLevel