It really depends on what you need to do, but I strongly suggest you to take a look at pry that lets you do great things:
[1] pry(main)> require 'cgi'
=> true
[2] pry(main)> show-method CGI::escape
From: /home/carlesso/.rbenv/versions/2.1.2/lib/ruby/2.1.0/cgi/util.rb @ line 7:
Owner: CGI::Util
Visibility: public
Number of lines: 6
def escape(string)
encoding = string.encoding
string.b.gsub(/([^ a-zA-Z0-9_.-]+)/) do |m|
'%' + m.unpack('H2' * m.bytesize).join('%').upcase
end.tr(' ', '+').force_encoding(encoding)
end
and even more strange stuff:
[4] pry(main)> cd CGI
[5] pry(CGI):1> ls
constants:
Cookie CR EOL HtmlExtension HTTP_STATUS InvalidEncoding LF MAX_MULTIPART_COUNT MAX_MULTIPART_LENGTH NEEDS_BINMODE PATH_SEPARATOR QueryExtension REVISION Util
Object.methods: yaml_tag
CGI::Util#methods:
escape escapeElement escapeHTML escape_element escape_html h pretty rfc1123_date unescape unescapeElement unescapeHTML unescape_element unescape_html
CGI.methods: accept_charset accept_charset= parse
CGI#methods: accept_charset header http_header nph? out print
class variables: @@accept_charset
locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_
you can also edit something, like edit CGI::escape
will open your $EDITOR
to the relevant file/line (in my case, vim will be opened at .rbenv/versions/2.1.2/lib/ruby/2.1.0/cgi/util.rb
line 7
Where present will show the help:
[10] pry(CGI):1> help Pry.hist
Usage: hist [--head|--tail]
hist --all
hist --head N
hist --tail N
hist --show START..END
hist --grep PATTERN
hist --clear
hist --replay START..END
hist --save [START..END] FILE
Aliases: history
Show and replay Readline history.
-a, --all Display all history
-H, --head Display the first N items
-T, --tail Display the last N items
-s, --show Show the given range of lines
-G, --grep Show lines matching the given pattern
-c, --clear Clear the current session's history
-r, --replay Replay a line or range of lines
--save Save history to a file
-e, --exclude-pry Exclude Pry commands from the history
-n, --no-numbers Omit line numbers
-h, --help Show this message.
But, again, it really depends on your needs, a little bit of "metaprogramming" can help you, like .methods
, .instance_variables
, .constants
can be useful..