Forum: Ruby on Rails Find all the methods on a object in an irb session?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4f0c9dc6cf209d996ab24502ee5c7f2f?d=identicon&s=25 Bothari (Guest)
on 2006-03-12 22:19
(Received via mailing list)
How can I find all the methods on an object from withing irb?

Thanks,
Joe
3ec705c5dd3480c6268b72c5617e8dae?d=identicon&s=25 Michael Smedberg (Guest)
on 2006-03-12 22:34
(Received via mailing list)
Have you tried the "methods" method?  E.g.:

irb(main):001:0> x = "test"
=> "test"
irb(main):002:0> x.methods
=> ["send", "%", "rindex", "between?", "reject", "[]=", "split", "<<",
"object_i
d", "strip", "size", "singleton_methods", "downcase", "gsub!", "count",
"succ!",
 "__send__", "downcase!", "intern", "member?", "squeeze!", "equal?",
"taint", "*
", "next", "find", "frozen?", "instance_variable_get",
"each_with_index",
"rstri
p!", "each_line", "+", "kind_of?", "sub", "slice!", "instance_eval",
"require",
"to_a", "tr", "replace", "collect", "reverse", "all?", "type",
"entries",
"lstri
p", "protected_methods", "capitalize", "chop!", "extend", "capitalize!",
"scan",
 "to_sym", "detect", "eql?", "instance_variable_set", "zip",
"each_byte",
"is_a?
", "casecmp", "hash", "gsub", "empty?", "to_str", "map", "to_s", "tr_s",
"any?",
 "tr!", "class", "match", "sort", "rstrip", "tainted?",
"private_methods",
"next
!", "swapcase", "min", "chomp!", "require_gem_with_options",
"swapcase!",
"ljust
", "untaint", "find_all", "upto", "hex", "each", "sum", "id",
"reverse!",
"chop"
, "to_i", "insert", "<", "inject", "<=>", "inspect", "delete", "dump",
"==",
"tr
_s!", "unpack", ">", "concat", "===", "clone", "succ", "sort_by",
"public_method
s", "strip!", "max", "rjust", ">=", "respond_to?", "display", "freeze",
"index",
 "select", "<=", "slice", "oct", "__id__", "to_f", "length", "chomp",
"methods",
 "upcase", "partition", "=~", "sub!", "squeeze", "require_gem",
"method",
"upcas
e!", "crypt", "delete!", "nil?", "dup", "grep", "instance_variables",
"lstrip!",
 "include?", "instance_of?", "center", "[]"]
E24b2a1d71b7365186a934a09ee6f7c3?d=identicon&s=25 Carl-Johan Kihlbom (Guest)
on 2006-03-12 22:34
(Received via mailing list)
Just call the method "methods" on the object, i.e:

an_object.methods
This topic is locked and can not be replied to.