From: "Thomas B." Date: 2008-10-13T16:23:47+09:00 Subject: Re: why the object doesn't respond to its method? Li Chen wrote: > It seems to me that respond_to?() cannot detect the methods in either > getters or setters. Is it true? If this is case what methods can be > detected by respond_to?() ? The ole methods cannot be detected by respond_to?. This is exactly what I have been trying to communicate to you, since the first post. In general, respond_to? detects all methods of all object. Ole objects are sort of exception here - ole methods are not detected by respond_to?, but other methods are. If you have any object of any of the standard Ruby classes, it will always work as expected - respond_to? returns true iff the object responds to this method. > But how about ole_methods? I only > know it will return more methods. And most of them cannot detected by > respond_to?(),either. It just returns all the ole methods, both setters and non-setters, all messed up together. You will see that excel.ole_methods includes a method named Visible twice - one of them is the setter and the other is the getter. The only way to tell which is which (the only that I know for now, but note that I was never really working with ole objects) is to call the method's return_type method, like this: irb(main):075:0> voice.ole_methods.select{|m| m.to_s=="Voice"}.each{|m| p m.return_type_detail} ["PTR", "USERDEFINED", "ISpeechObjectToken"] ["VOID"] But I don't know how to interpret the results. But we at least see now that these are two distinct methods, even though both are reported to be named Voice. TPR. -- Posted via http://www.ruby-forum.com/.