Class: String

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

Class Method Summary collapse

Class Method Details

.try_convert(obj) ⇒ Object

Raises:

  • (TypeError)


32
33
34
35
36
37
38
# File 'lib/friendfeed/compat.rb', line 32

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