Modified: MacRuby/branches/icu/string.c (3670 => 3671)
--- MacRuby/branches/icu/string.c 2010-03-03 01:33:12 UTC (rev 3670)
+++ MacRuby/branches/icu/string.c 2010-03-03 01:35:59 UTC (rev 3671)
@@ -1175,6 +1175,24 @@
/*
* call-seq:
+ * String.try_convert(obj) -> string or nil
+ *
+ * Try to convert <i>obj</i> into a String, using to_str method.
+ * Returns converted regexp or nil if <i>obj</i> cannot be converted
+ * for any reason.
+ *
+ * String.try_convert("str") # => str
+ * String.try_convert(/re/) # => nil
+ */
+
+static VALUE
+rstr_try_convert(VALUE self, SEL sel, VALUE other)
+{
+ return rb_check_string_type(other);
+}
+
+/*
+ * call-seq:
* String.new(str="") => new_str
*
* Returns a new string object containing a copy of <i>str</i>.
@@ -3873,6 +3891,8 @@
rb_const_set(rb_cObject, rb_intern("String"), rb_cRubyString);
rb_objc_define_method(*(VALUE *)rb_cRubyString, "alloc", rstr_alloc, 0);
+ rb_objc_define_method(*(VALUE *)rb_cRubyString, "try_convert",
+ rstr_try_convert, 1);
rb_objc_define_method(rb_cRubyString, "initialize", rstr_initialize, -1);
rb_objc_define_method(rb_cRubyString, "initialize_copy", rstr_replace, 1);
rb_objc_define_method(rb_cRubyString, "dup", rstr_dup, 0);