Reputation: 93216
I wonder how one can list all methods in a module, but not including inherited methods.
eg.
module Software
def exit
puts "exited"
end
end
puts Software.methods
Will list not only exit, but all inherited methods.
Is is possible to just list exit?
Thanks
Upvotes: 37
Views: 19866
Reputation: 370172
Actually Software.methods
will not list exit
. Software.instance_methods
will list exit
as well as any inherited methods (which in this case is nothing because modules don't inherit any methods unless you include another module). Software.instance_methods(false)
will only list methods defined in Software
.
Upvotes: 57