Esempio n. 1
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, Thread /*!*/ self)
        {
            RubyThreadInfo.RegisterThread(Thread.CurrentThread);

            MutableString result = MutableString.CreateMutable();

            result.Append("#<");
            result.Append(RubyUtils.GetClassName(context, self));
            result.Append(':');
            RubyUtils.AppendFormatHexObjectId(result, RubyUtils.GetObjectId(context, self));
            result.Append(' ');

            if ((self.ThreadState & ThreadState.WaitSleepJoin) != 0)
            {
                result.Append("sleep");
            }
            else if ((self.ThreadState & (ThreadState.Stopped | ThreadState.Aborted | ThreadState.AbortRequested)) != 0)
            {
                result.Append("dead");
            }
            else
            {
                result.Append("run");
            }

            result.Append('>');
            return(result);
        }
Esempio n. 2
0
        public static MutableString TagUri(RubyContext /*!*/ context, object self)
        {
            MutableString str = MutableString.Create("!ruby/object:");

            str.Append(RubyUtils.GetClassName(context, self));
            return(str);
        }
Esempio n. 3
0
 public static int Limit(RubyContext /*!*/ context, RubyClass /*!*/ self, [Optional] object n)
 {
     if (!(n is Missing))
     {
         throw RubyExceptions.CreateTypeError("wrong argument type " + RubyUtils.GetClassName(self.Context, n) + " (expected Fixnum)");
     }
     return(GetConfig(context).Limit);
 }
Esempio n. 4
0
        private static RubyIO /*!*/ ToIo(RubyContext /*!*/ context, object obj)
        {
            RubyIO io = obj as RubyIO;

            if (io == null)
            {
                throw RubyExceptions.CreateTypeConversionError(RubyUtils.GetClassName(context, obj), "IO");
            }
            return(io);
        }
Esempio n. 5
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, RubyEncoding /*!*/ self)
        {
            // TODO: to_s overridden
            MutableString result = MutableString.CreateMutable();

            result.Append("#<");
            result.Append(RubyUtils.GetClassName(context, self));
            result.Append(':');
            result.Append(self.Name);
            result.Append(">");
            return(result);
        }
Esempio n. 6
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, Exception /*!*/ self)
        {
            object message   = RubyExceptionData.GetInstance(self).Message;
            string className = RubyUtils.GetClassName(context, self);

            MutableString result = MutableString.CreateMutable();

            result.Append("#<");
            result.Append(className);
            result.Append(": ");
            if (message != null)
            {
                result.Append(KernelOps.Inspect(context, message));
            }
            else
            {
                result.Append(className);
            }
            result.Append('>');
            return(result);
        }
Esempio n. 7
0
 public static int InducedFrom(RubyClass /*!*/ self, object obj)
 {
     throw RubyExceptions.CreateTypeError(String.Format("failed to convert {0} into Integer", RubyUtils.GetClassName(self.Context, obj)));
 }
Esempio n. 8
0
 public static double InducedFrom(RubyClass /*!*/ self, object value)
 {
     throw RubyExceptions.CreateTypeError(String.Format("failed to convert {0} into Float", RubyUtils.GetClassName(self.Context, value)));
 }
Esempio n. 9
0
 public static Node ToYamlNode(RubyContext /*!*/ context, object self, RubyRepresenter rep)
 {
     throw RubyExceptions.CreateTypeError("can't dump anonymous class " + RubyUtils.GetClassName(context, self));
 }
Esempio n. 10
0
 // Calls to_hash on the object, if it's not already a dictionary
 // (only certain Hash functions use this in Ruby)
 internal static IDictionary <object, object> ConvertToHash(RubyContext /*!*/ context, object hash)
 {
     try {
         IDictionary <object, object> dict = hash as IDictionary <object, object>;
         return(dict != null ? dict : RubySites.ToHash(context, hash));
     } catch (MissingMethodException e) {
         throw new InvalidOperationException(String.Format("can't convert {0} into Hash", RubyUtils.GetClassName(context, hash)), e);
     }
 }
Esempio n. 11
0
 public static object SquareRoot(RubyContext /*!*/ context, BigDecimal /*!*/ self, object n)
 {
     throw RubyExceptions.CreateTypeError("wrong argument type " + RubyUtils.GetClassName(context, n) + " (expected Fixnum)");
 }
Esempio n. 12
0
 public static BigDecimal InducedFrom(RubyClass /*!*/ self, object value)
 {
     throw RubyExceptions.CreateTypeConversionError(RubyUtils.GetClassName(self.Context, value), self.Name);
 }
Esempio n. 13
0
 /// <summary>
 /// Check that the object responds to "succ".
 /// </summary>
 private static void CheckBegin(RubyContext /*!*/ context, object begin)
 {
     if (!RubySites.RespondTo(context, begin, "succ"))
     {
         throw RubyExceptions.CreateTypeError(String.Format("can't iterate from {0}", RubyUtils.GetClassName(context, begin)));
     }
 }
Esempio n. 14
0
 public static RubyArray Coerce(RubyContext /*!*/ context, BigInteger /*!*/ self, object other)
 {
     throw RubyExceptions.CreateTypeError(String.Format("can't coerce {0} to Bignum", RubyUtils.GetClassName(context, other)));
 }