How can I find all the methods on an object from withing irb? Thanks, Joe
Michael Smedberg
2006-Mar-12 21:32 UTC
[Rails] Find all the methods on a object in an irb session?
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", "[]"] On 3/12/06, Bothari <bothari@gmail.com> wrote:> > How can I find all the methods on an object from withing irb? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060312/cfb81960/attachment-0001.html
Carl-Johan Kihlbom
2006-Mar-12 21:34 UTC
[Rails] Find all the methods on a object in an irb session?
Just call the method "methods" on the object, i.e: an_object.methods On 3/12/06, Bothari <bothari@gmail.com> wrote:> How can I find all the methods on an object from withing irb? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >