From: ptkwt@... (Phil Tomson) Date: 2004-08-27T16:05:35+09:00 Subject: Re: Short question In article <20040827.074607.71100747.Meino.Cramer@gmx.de>, Meino Christian Cramer wrote: >Hi, > > just a short question: > > Is there a way to "ask" an object or class what methods are available > from it? > > This is not meant to be used inside a program but just as a quick > check, what I can do with what. > > Ruby.use! > Meino > > try: instance_methods methods example: irb(main):001:0> class Foo irb(main):002:1> def foo irb(main):003:2> "foo" irb(main):004:2> end irb(main):005:1> end irb(main):010:0> Foo.instance_methods => ["clone", "display", "protected_methods", "freeze", "instance_variable_set", "foo", "is_a?", "type", "methods", "method", "=~", "send", "instance_of?", "__id__", "instance_variables", "to_s", "eql?", "dup", "hash", "private_methods", "nil?", "tainted?", "class", "singleton_methods", "extend", "instance_eval", "untaint", "__send__", "instance_variable_get", "object_id", "kind_of?", "inspect", "taint", "frozen?", "==", "public_methods", "id", "respond_to?", "===", "equal?", "to_a"] irb(main):011:0> f = Foo.new => # irb(main):012:0> f.methods => ["clone", "display", "protected_methods", "freeze", "instance_variable_set", "foo", "is_a?", "type", "methods", "method", "=~", "send", "instance_of?", "__id__", "instance_variables", "to_s", "eql?", "dup", "hash", "private_methods", "nil?", "tainted?", "class", "singleton_methods", "extend", "instance_eval", "untaint", "__send__", "instance_variable_get", "object_id", "kind_of?", "inspect", "taint", "frozen?", "==", "public_methods", "id", "respond_to?", "===", "equal?", "to_a"] Phil