[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

I'm a new member

Qu?nh Tr?n

12/3/2006 7:49:00 AM

Hi evrybody!
I'm a new member of forum ruby .
I meet with serious difficulties
Can you help me?
I have project write for compare different C++ with ruby (EX: Class
String )
thanks.

--
Posted via http://www.ruby-....

22 Answers

Paul Lutus

12/3/2006 9:13:00 AM

0

Que1bbb3nh Tre1baa7n wrote:

> Hi evrybody!
> I'm a new member of forum ruby .
> I meet with serious difficulties
> Can you help me?

Certainly. Please state the problem.

--
Paul Lutus
http://www.ara...

Eric Hodel

12/3/2006 10:02:00 AM

0

On Dec 2, 2006, at 23:49 , Qu?nh Tr?n wrote:
> Can you help me?
> I have project write for compare different C++ with ruby (EX: Class
> String )

I don't know about C++ strings, what are they like?

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!


Li Chen

12/3/2006 10:07:00 AM

0

Hi all,

I want to print all the methods in excel OLE object
in alphabetic order but the sort method is
unavailable. Can anyone explain it and help me fix it?

Thank you,

Li
##
require 'win32ole'
excel = WIN32OLE.new('Excel.Application')
m = excel.ole_methods
p m.class
p m.sort

##screen output
>ruby sort1.rb
Array
sort1.rb:6:in `sort': undefined method `<=>' for
Rows:WIN32OLE_METHOD (NoMethodError)
from sort1.rb:6
>Exit code: 1



____________________________________________________________________________________
Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.com

Qu?nh Tr?n

12/3/2006 10:24:00 AM

0

Hi all!

Li Chen wrote:
> I want to print all the methods in excel OLE object
> in alphabetic order but the sort method is
> unavailable. Can anyone explain it and help me fix it?
>
> Thank you,
>

sorry
could you like to make yourself clear !
thanks.

--
Posted via http://www.ruby-....

Paul Lutus

12/3/2006 10:35:00 AM

0

Eric Hodel wrote:

> On Dec 2, 2006, at 23:49 , Quỳnh Trần wrote:
>> Can you help me?
>> I have project write for compare different C++ with ruby (EX: Class
>> String )
>
> I don't know about C++ strings, what are they like?

That depends. If the OP is describing ordinary C++ strings (not the string
class), they are like a traditional C string, e.g. a series of characters
terminated with a zero byte. If the OP is referring to ANSI strings, this
page may help describe it:

http://www.msoe.edu/eecs/ce/courseinfo/stl/...

Unfortunately the original post doesn't say clearly which "string" is meant.

--
Paul Lutus
http://www.ara...

Paul Lutus

12/3/2006 10:41:00 AM

0

chen li wrote:

> Hi all,
>
> I want to print all the methods in excel OLE object
> in alphabetic order but the sort method is
> unavailable. Can anyone explain it and help me fix it?
>
> Thank you,
>
> Li
> ##
> require 'win32ole'
> excel = WIN32OLE.new('Excel.Application')
> m = excel.ole_methods
> p m.class
> p m.sort
>
> ##screen output
>>ruby sort1.rb
> Array
> sort1.rb:6:in `sort': undefined method `<=>' for
> Rows:WIN32OLE_METHOD (NoMethodError)
> from sort1.rb:6
>>Exit code: 1

One solution is to convert the entire OLE data array into an equivalent Ruby
type, such as an array of Ruby strings, and sort those. In this case, you
could take the "excel.ole_methods" list and insert it into a Ruby array,
hopefully as strings, and sort the resulting array.

--
Paul Lutus
http://www.ara...

David Vallner

12/3/2006 10:42:00 AM

0

Qu?nh Tr?n wrote:
> Hi all!
>
> Li Chen wrote:
>> I want to print all the methods in excel OLE object
>> in alphabetic order but the sort method is
>> unavailable. Can anyone explain it and help me fix it?
>>
>> Thank you,
>>
>
> sorry
> could you like to make yourself clear !
> thanks.
>

That was a thread hijack. Either there's a problem with one of the
gateways that makes new threads appear as replies to old ones, or Some
People Don't Know Better (tm).

Either way, it wasn't supposed to be an answer to your problem.

David Vallner

Martin DeMello

12/3/2006 11:19:00 AM

0

On 12/3/06, chen li <chen_li3@yahoo.com> wrote:
> ##
> require 'win32ole'
> excel = WIN32OLE.new('Excel.Application')
> m = excel.ole_methods
> p m.class
> p m.sort

sort_by is your friend. I don't have a windows machine handy to
experiment, but say an Rows:WIN32OLE_METHOD defines a #name, you can
say

p m.sort_by {|i| i.name}

or even

m.map {|i| i.name}.sort

if what you want is the names, rather than the Rows:WIN32OLE_METHOD
objects themselves.

Of course, if you *can* print it, it evidently defines to_s and
inspect methods, so this will work:

puts m.map {|i| i.to_s}.sort

or

puts m.map {|i| i.inspect}.sort

martin

Li Chen

12/3/2006 2:48:00 PM

0


--- Martin DeMello <martindemello@gmail.com> wrote:
>
> sort_by is your friend. I don't have a windows
> machine handy to
> experiment, but say an Rows:WIN32OLE_METHOD defines
> a #name, you can
> say
>
> p m.sort_by {|i| i.name}
>
> or even
>
> m.map {|i| i.name}.sort
>
> if what you want is the names, rather than the
> Rows:WIN32OLE_METHOD
> objects themselves.
>
> Of course, if you *can* print it, it evidently
> defines to_s and
> inspect methods, so this will work:
>
> puts m.map {|i| i.to_s}.sort
>
> or
>
> puts m.map {|i| i.inspect}.sort
>
> martin

Thanks and all of them work. But I just don't
understand why the line code below works

p m.sort_by {|i| i.name}

yet p m.sort.each{|i| i.name} FAILS.

Li






____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail...

dblack

12/3/2006 2:59:00 PM

0