Home > Archive > Ruby > August 2005 > Win32ole object collection mapping to array ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Win32ole object collection mapping to array ?
|
|
| Peter Fitzgibbons 2005-08-28, 6:58 pm |
| Hello all,
I have a win32ole object collection that I want to map, then sort, to an
array?
Each item has #Name property. I'm thinking of making an arry of hashes
a'la :
> items = []
> oleItems.each {|o| items << {o.Name => o} }
> items
[{"0172"=>#<WIN32OLE:0x2a88570>}, {"0171"=>#<WIN32OLE:0x2a88540>}]
But then, how do I sort the array of hashes ?
Is there a better approach ?
Peter J. Fitzgibbons
Applications Manager
Lakewood Homes - "The American Dream Builder"(r)
Peter.Fitzgibbons@Lakewoodhomes.net
(847) 884-8800
| |
| Brian Takita 2005-08-28, 6:59 pm |
| Sorry. What I gave you is wrong. Daniel has a good solution.
On 8/25/05, Brian Takita <brian.takita@gmail.com> wrote:
>
> Try this...
>
>
> On 8/25/05, Peter Fitzgibbons <Peter.Fitzgibbons@lakewoodhomes.net >
> wrote:
>
| |
| tokmak tokmak 2005-08-31, 7:57 am |
| You can try this (apologies if i misunderstood you problem):
oleitems.map{|o| o.Name}.sort
This makes an array of Name values, then sorts it. I couldn't understand if
you want values as an array or hash.
On 8/25/05, Peter Fitzgibbons <Peter.Fitzgibbons@lakewoodhomes.net> wrote:
>
> Hello all,
>
> I have a win32ole object collection that I want to map, then sort, to an
> array?
>
> Each item has #Name property. I'm thinking of making an arry of hashes
> a'la :
>
> [{"0172"=>#<WIN32OLE:0x2a88570>}, {"0171"=>#<WIN32OLE:0x2a88540>}]
>
> But then, how do I sort the array of hashes ?
>
> Is there a better approach ?
>
> Peter J. Fitzgibbons
> Applications Manager
> Lakewood Homes - "The American Dream Builder"(r)
> Peter.Fitzgibbons@Lakewoodhomes.net
> (847) 884-8800
>
>
>
>
|
|
|
|
|