123456789_123456789_123456789_123456789_123456789_

Module: Matrix::ConversionHelper

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Included In:
Defined in: lib/matrix.rb

Overview

Private helper modules

Instance Method Summary

Instance Method Details

#convert_to_array(obj, copy = false) (private)

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

[ GitHub ]

  
# File 'lib/matrix.rb', line 1487

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