From: Ned Konz Date: 2002-07-06T07:58:00+09:00 Subject: Re: VIM/ruby On Friday 05 July 2002 03:11 pm, Steve Tuckner wrote: > I am want to build a class or set of classes to use in VIM so that > I can more easily script vim/ruby. The problem with the current set > of classes is that I want VIM::Buffer, VIM::Window, and the buffer > lists to act > > just like arrays so that I could do the following: > : ruby $curbuf.sort {|a,b| a.to_i <=> b.to_i} > > My solution is to build a proxy class for the lines in a buffer > that is > > a sub-class of an array so that I would be able to do the following: > : ruby VIMbuf($curbuf).sort {|a,b| a.to_i <=> b.to_i} > > Is there a better way to do this or should I proceed as above? You don't need to subclass Array at all to do this. Just mix in Enumerable and define each(). For instance, source this in Vim: ruby <