I've decided to inherit from array after all, since all I want to do 
with this is extend support for multidimensional arrays, but without 
overwriting any of Array's methods.

Anyway, the obstacle I've hit is one I can avoid, but I was wondering 
whether I'm doing something wrong, or whether there's a nice Rubyish way 
around this. Here's a simplified version to demonstrate the issue:

___________________
class Excel_Sheet<Array

  def initialize( val=[] )
    val = %w(A1 B1 C1 A2 B2 C2 A3 B3 C3).each_slice(3).to_a if val == 
'test'
    super ( val )
  end

  def skip_headers
    block_given? ? ( [ self[0] ] + yield( self[1..-1] ) ) : ( 
self[1..-1] )
  end

  def filter( header, regex )
    idx = self[0].index header
    skip_headers { |xl| xl.select { |ar| ar[idx] =~ regex } }
  end

end
___________________

When I do this sort of thing:
result = object.filter('Header', /value1|value2/)

I get the return as an Array, so I can't use my extra methods on it 
anymore.

Here's my current workaround. It's the only way I could think of doing 
this but it doesn't look right.
___________________
def filter( header, regex )
  idx = self[0].index header
  Excel_Sheet.new skip_headers { |xl| xl.select { |ar| ar[idx] =~ regex 
} }
end
___________________

So in short, my question is how can I return my class type after using 
Array's methods on my child-class?

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