Class: Object

Inherits:
BasicObject
Defined in:
lib/rubinius/bridge/object.rb

Instance Method Summary collapse

Instance Method Details

#StringValue(obj) ⇒ Object

Raises:

  • (TypeError)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubinius/bridge/object.rb', line 2

def StringValue(obj)
  return obj if obj.kind_of?(String)

  begin
    obj.to_str
  rescue Exception => orig
    raise TypeError,
          "Coercion error: #{obj.inspect}.to_str => String failed",
          orig
  end

  return ret if ret.kind_of?(String)

  msg = "Coercion error: obj.to_st did NOT return a String (was #{ret.class})"
  raise TypeError, msg
end