How to see core ruby/library sources?
I wanted to see how Ruby's arrays implement the functionality for an iterator -- say inject.
So, I use inject in Ruby code and do Ctrl+B when caret is on "inject". It takes me to array.rb.inject. But this happens to be the "stub, used for indexing".
Is there a way to see actual library source code? (Again, I am drawing parallels between RubyMine and IDEA. The latter provides a nice way to grok the JDK sources).
Regards,
Kedar
Please sign in to leave a comment.
Hello Kedar,
Actually Ruby runtime doesn't have any ruby sources for such a system classes, instead of the ruby sources it uses natively compiled classes written in plain C in case of MRI Ruby.
However RubyMine requires such an information to give you correct code completion and code validation, so we've generated stubs which you see when perform goto declaration.
Regards,
Oleg
Thank you, Oleg. Yes, I use MRI. This must have been done for performance reasons. Do you know where I can read about this? Is there any other Ruby implementation that implements these System classes in pure Ruby?
I guess the easiest way is to install any Ruby runtime via rvm and browse source code :)