tags:

views:

37

answers:

2

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

A: 
Software.public_instance_methods

seems to work for your example.

Beanish
+2  A: 

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.

sepp2k