Introspection of a class
suggest changeTake this class definition:
class A
def a; end
end
module B
def b; end
end
class C < A
include B
def c; end
end
What are the instance methods of C?
C.instance_methods # [:c, :b, :a, :singleton_class, ...]
to_json appears in that list only after json is loaded. What are the instance methods defined only on C?
C.instance_methods(false) # [:c]
What are the ancestors of class C?
C.ancestors # [C, B, A, Object,...]
Superclass of C?
C.superclass # A
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents