[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

win32ole and ole_methods

djberg96

11/9/2004 10:32:00 PM

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
5 Answers

Masaki Suketa

11/10/2004 4:12:00 PM

0

Hello,

In message "win32ole and ole_methods"
on 04/11/10, Daniel Berger <djberg96@hotmail.com> writes:

> 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



Logan Capaldo

11/12/2004 2:26:00 AM

0

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



On Thu, 11 Nov 2004 01:11:40 +0900, Masaki Suketa
<masaki.suketa@nifty.ne.jp> wrote:
> Hello,
>
> In message "win32ole and ole_methods"
> on 04/11/10, Daniel Berger <djberg96@hotmail.com> writes:
>
> > 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
>
>


gabriele renzi

11/12/2004 10:25:00 AM

0

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

Masaki Suketa

11/12/2004 11:27:00 PM

0


In message "Re: win32ole and ole_methods"
on 04/11/12, Logan Capaldo <logancapaldo@gmail.com> writes:
>
> 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


Masaki Suketa

11/13/2004 2:23:00 AM

0

Hello,

In message "Re: win32ole and ole_methods"
on 04/11/12, gabriele renzi <rff_rff@remove-yahoo.it> writes:

> > 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

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