Ruby/Reflection/protected methods
Материал из Wiki.crossplatform.ru
Get the size of public methods
class SomeClass def initialize @a = 1 @b = 2 end def mymeth end protected :mymeth end x = SomeClass.new def x.newmeth end iv = x.instance_variables # ["@b", "@a"] meth = x.methods.size # 37 pub = x.public_methods.size # 37 pri = x.private_methods.size # 66 pro = x.protected_methods.size # 1 sm = x.singleton_methods.size # 1