Win32ole and ole_methods

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? :slight_smile:

Regards,

Dan

Hello,

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? :slight_smile:

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

路路路

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

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? :slight_smile:

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

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

  Regards,
  Masaki.Suketa

路路路

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 }

Hello,

> 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

路路路

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