Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/as_code.rb,
lib/classtree.rb,
ext/generate_cached.rb
Instance Method Summary collapse
- #as_code(indent = 0) ⇒ Object
- #classtree(s = '', prefix = '', obj = self, graphed = {}) ⇒ Object
-
#has_singleton? ⇒ Boolean
Return true if this object has a singleton class.
-
#real_class ⇒ Class
Return the object’s first immediate ancestor; this may be the object’s class, its singleton class, or a module singleton.
-
#singleton? ⇒ Boolean
Return true if this object is a singleton (that is, it has the FL_SINGLETON flag set).
-
#singleton_class ⇒ Class
Return the object’s singleton class.
Instance Method Details
#as_code(indent = 0) ⇒ Object
342 343 344 345 |
# File 'lib/as_code.rb', line 342 def as_code(indent=0) # TODO: this won't work for many objects "#{' '*indent}#{self.inspect}" end |
#classtree(s = '', prefix = '', obj = self, graphed = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/classtree.rb', line 4 def classtree(s = '', prefix = '', obj=self, graphed={}) # if Module == obj.class.class then # s << "included module " # elsif obj.singleton? then # s << "singleton class " # elsif Class === obj then # s << "class " # end s << "#{obj}" if graphed[obj] then s << " (*)\n" return s end s << "\n" graphed[obj] = true return if Kernel == obj subtree = (Module === obj) && (obj.real_superclass) s << "#{prefix}#{subtree ? '|-' : '+-'}class = " classtree(s, prefix + (subtree ? '| ' : ' '), obj.real_class, graphed) if subtree then s << "#{prefix}+-super = " classtree(s, prefix + ' ', obj.real_superclass, graphed) end return s end |
#has_singleton? ⇒ Boolean
Return true if this object has a singleton class.
2313 2314 2315 2316 |
# File 'ext/nodewrap.c', line 2313
VALUE has_singleton(VALUE self)
{
return FL_TEST(RBASIC(self)->klass, FL_SINGLETON) ? Qtrue : Qfalse;
}
|
#real_class ⇒ Class
Return the object’s first immediate ancestor; this may be the object’s class, its singleton class, or a module singleton.
2290 2291 2292 2293 |
# File 'ext/nodewrap.c', line 2290
VALUE real_class(VALUE self)
{
return RBASIC(self)->klass;
}
|
#singleton? ⇒ Boolean
Return true if this object is a singleton (that is, it has the FL_SINGLETON flag set).
2302 2303 2304 2305 |
# File 'ext/nodewrap.c', line 2302
VALUE is_singleton(VALUE self)
{
return FL_TEST(self, FL_SINGLETON) ? Qtrue : Qfalse;
}
|
#singleton_class ⇒ Class
Return the object’s singleton class. Creats a new singleton class for the object if it does not have one. See RCR#231.
2325 2326 2327 2328 |
# File 'ext/nodewrap.c', line 2325
VALUE singleton_class(VALUE self)
{
return rb_singleton_class(self);
}
|