Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/friendfeed/compat.rb

Class Method Summary collapse

Class Method Details

.try_convert(obj) ⇒ Object

Raises:

  • (TypeError)


42
43
44
45
46
47
48
# File 'lib/friendfeed/compat.rb', line 42

def self.try_convert(obj)
  return obj if obj.instance_of?(self)
  return nil if !obj.respond_to?(:to_ary)
  nobj = obj.to_ary 
  return nobj if nobj.instance_of?(self)
  raise TypeError, format("can't convert %s to %s (%s#to_ary gives %s)", obj.class, self.class, obj.class, nobj.class)
end