Class: IO

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

Class Method Summary collapse

Class Method Details

.try_convert(obj) ⇒ Object

Raises:

  • (TypeError)


22
23
24
25
26
27
28
# File 'lib/friendfeed/compat.rb', line 22

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