In Ruby, if i am looking for the methods of a class.
ie:String.methods.sort
and i have the following:
[:!, :!=, :!~, :<, :<=, :<=>, :==,
If you use Pry
, it has a handy shortcut, show-source
:
[1] pry(main)> show-source String.display
From: io.c (C Method):
Owner: Kernel
Visibility: public
Number of lines: 15
static VALUE
rb_obj_display(int argc, VALUE *argv, VALUE self)
{
VALUE out;
if (argc == 0) {
out = rb_stdout;
}
else {
rb_scan_args(argc, argv, "01", &out);
}
rb_io_write(out, self);
return Qnil;
}
You can use
help 'String#display'
and it'll show the rdoc for the method (the same output that would show from running ri 'String#display'
outside of irb. You can also just type help
into irb and it'll go into a mode where you can just keep typing method names and it'll show the rdoc (enter a blank line to exit).