What methods can I use here?
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Ruby is a great and powerful language, you can do some really cool stuff. But sometimes, as a developer, you're typing some code and you are at a place where you wished you had some superintelligent, real cool context-sensitive intellisense that you could use to see which method exactly you can use at that place. But we all use {vim|emacs|textmate|…} which are simple but effective editors. Although there's some completion you can use, it will not provide completion for some fancy module you've included, but you know it's there. Sure, you can go through the documentation, but still you're not sure whether it is there or not.

I find myself, from time to time, wondering “what methods can I use here?”. Sure, I can fireup Rubymine and hope it's intelligent enough to interpret my whole project and tell me perfectly all the methods I can use when I tab CTRL-SPACE. Most of the times, I'm disappointed by the fact Im not getting what I wanted.

Enter 'reflectorr', it provides one single method called 'show_methods' which you can use everywhere in your code and it returns a hash containing every included module as the key and an array of methods you can call at that place where you called it.

An example:

require 'pp'
require 'reflectorr'
class MyClass
    def an_instance_method
    def self.a_class_method
    pp show_methods
    def self.a_second_class_method

And this will return this

{"Object"=>        ["yaml_tag_subclasses?"],
  "Kernel"=>       ["test",
 "MyClass"=>        ["a_class_method"]}

You can see it will show for 'MyClass' only the method 'a_class_method'. 'a_second_class_method' is defined after the 'show_methods' call and isn't available yet. So keep this in mind also.

So have fun, I hope you'll learn from it, and find it useful. If not, just discard this :).


0.2.0: Total rewrite in order to include more ways of extending/excluding your class in the result.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


Copyright © 2010 Christiaan Van den Poel. See LICENSE for details.