Ruby/Reflection/Object

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Содержание

inquire after instance methods with a method from Module

p Object.instance_methods.sort



protected_methods

p Object.protected_methods.sort



public_methods

p Object.public_methods.sort



query about methods with the Object methods private_methods,

p Object.private_methods.sort



Reflection on Methods

# method returns a list publicly accessible methods from an object, including the methods accessible 
# from the ancestors of the object. 
p Object.methods.sort



singleton_methods.

p Object.singleton_methods.sort



Want to know what constants the Object class (or some other class) has? Use the constants method from Module (output is truncated):

p Object.constants.sort