示例#1
0
 protected void DoCoerce(object o, out RNumeric x, out RNumeric y)
 {
     x = y = null;
     try
     {
         RArray a = (RArray)ruby.Funcall(o, "coerce", this);
         if (a == null || a.Count != 2)
             throw new eTypeError("coerce must return [x, y]");
         x = (RNumeric)a[0];
         y = (RNumeric)a[1];
     }
     catch
     {
         throw new eTypeError(String.Format("{0} can't be coerced into {1}",
                                            IsSpecialConstType(o) ?
                                                ruby.Inspect(o) : ruby.ClassOf(o).Name,
                                            ruby.ClassOf(this).Name));
     }
 }
示例#2
0
 protected void DoCoerce(object o, out RNumeric x, out RNumeric y)
 {
     x = y = null;
     try
     {
         RArray a = (RArray)ruby.Funcall(o, "coerce", this);
         if (a == null || a.Count != 2)
         {
             throw new eTypeError("coerce must return [x, y]");
         }
         x = (RNumeric)a[0];
         y = (RNumeric)a[1];
     }
     catch
     {
         throw new eTypeError(String.Format("{0} can't be coerced into {1}",
                                            IsSpecialConstType(o) ?
                                            ruby.Inspect(o) : ruby.ClassOf(o).Name,
                                            ruby.ClassOf(this).Name));
     }
 }