module Matrix::ConversionHelper

def convert_to_array(obj, copy = false) # :nodoc:

:nodoc:

a copy of obj will be made if necessary.
Converts the obj to an Array. If copy is set to true

:nodoc:
def convert_to_array(obj, copy = false) # :nodoc:
  case obj
  when Array
    copy ? obj.dup : obj
  when Vector
    obj.to_a
  else
    begin
      converted = obj.to_ary
    rescue Exception => e
      raise TypeError, "can't convert #{obj.class} into an Array (#{e.message})"
    end
    raise TypeError, "#{obj.class}#to_ary should return an Array" unless converted.is_a? Array
    converted
  end
end