win32ole and ole_methods

D

Daniel Berger

Hi,

This question falls into the, "I'm just curious as to why this is"
category. I noticed that the WIN32OLE#ole_methods (and
ole_func_methods, etc) return an array of WIN32OLE_METHOD objects.

Since I just want a list of methods, why not just return an array of
strings? If we must return WIN32OLE_METHOD objects, can the '<=>'
operator be defined so that I can sort them? :)

Regards,

Dan
 
M

Masaki Suketa

Hello,

In message "win32ole and ole_methods"
Since I just want a list of methods, why not just return an array of
strings? If we must return WIN32OLE_METHOD objects, can the '<=>'
operator be defined so that I can sort them? :)

Because in order to get the other information about the methods.
For example, you can get only the name of the method but also
argument information of the method.

oleobj.ole_methods.each do |m|
puts m.name
p m.params
end

You can the '<=>' method as following:

class WIN32OLE_METHOD
define <=>(other)
name <=> other.name
end
end

I welcom better idea, or better solution about this.

Regards

Masaki Suketa
 
L

Logan Capaldo

That seems a little overkill, why not just some_array.sort { |a, b|
a.name <=> b.name }
 
G

gabriele renzi

Logan Capaldo ha scritto:
That seems a little overkill, why not just some_array.sort { |a, b|
a.name <=> b.name }

well, but why should'nt it have a reasomnable default for the sort
routine? I'm for defining <=>, for what my opinion counts
 
M

Masaki Suketa

In message "Re: win32ole and ole_methods"
That seems a little overkill, why not just some_array.sort { |a, b|
a.name <=> b.name }

Yes, you are right. Or more simply, some_array.sort_by{|a| a.name}.

Regards,
Masaki.Suketa
 
M

Masaki Suketa

Hello,

In message "Re: win32ole and ole_methods"
well, but why should'nt it have a reasomnable default for the sort
routine? I'm for defining <=>, for what my opinion counts

If I can define the reasonable "<=>" method and it should have
the "<=>" method, then I am going to implement it.
So, I have a question.

Which is the reasonable WIN32OLE_METHOD#<=>,
method1.name <=> method2.name
or
method1.dispid <=> method2.dispid?

Is the former reasonable?

Regards,
Masaki Suketa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top