How to examine method signature ? (via Ruby introspection ?)

Summary:
I’m not guessing how to examine a method (or property ?), given its
name. Details below, in case I’m going far astray.

The sample code on page

http://httpd.chello.nl/k.vangelder/ruby/learntk/combining.html

specifically this line

image = TkPhotoImage.new() { file “background.gif”; height 50 }

is yielding me an error in number of arguments to height:

ruby stuff.rb
stuff.rb:14:in height': wrong number of arguments(1 for 0) (ArgumentError) from stuff.rb:14 from stuff.rb:14:in new’
from stuff.rb:14:in `new’
from stuff.rb:14

I think it would be good if I understood how to figure out the correct
number of
arguments to height using Ruby, but apparently I’m not clever enough
yet for this.

I have found that the class TkPhotoImage is a first class object, and
has some methods

TkPhotoImage.public_instance_methods

but none of them are “height”. So I tried to walk up the hierarchy
with a lucky guess

TkPhotoImage.superclass

TkImage

TkImage.public_instance_methods

Here I find “height”. But now I am not clever enough for the next step
(and I bet there is some simple next step, to see info about this
method/property)

TkImage.instance_method(“height”)

#<UnboundMethod: TkImage#height>

I wonder if someone could give me a suggestion or pointer about how I
should find out more info about the “height” property or method of the
class “TkImage” (preferably using Ruby, if that is reasonably easy).

Thanks for any ideas.

To find the number of arguments to a method:

TkImage.instance_method(“height”).arity

Negative values are returned if the arguments are variable (-1 = 0 or more,
-2 = 1 or more etc).

Regards,

Brian.

···

On Tue, Mar 11, 2003 at 07:48:29AM +0900, pj wrote:

TkImage

TkImage.public_instance_methods

Here I find “height”. But now I am not clever enough for the next step
(and I bet there is some simple next step, to see info about this
method/property)

TkImage.instance_method(“height”)

#<UnboundMethod: TkImage#height>

I wonder if someone could give me a suggestion or pointer about how I
should find out more info about the “height” property or method of the
class “TkImage” (preferably using Ruby, if that is reasonably easy).