Exemple #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);
        }
Exemple #2
0
        public static MutableString TagUri(RubyContext /*!*/ context, object self)
        {
            MutableString str = MutableString.Create("!ruby/object:");

            str.Append(RubyUtils.GetClassName(context, self));
            return(str);
        }
Exemple #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);
 }
Exemple #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);
        }
        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);
        }
Exemple #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);
        }
Exemple #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)));
 }
Exemple #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)));
 }
Exemple #9
0
 public static Node ToYamlNode(RubyContext /*!*/ context, object self, RubyRepresenter rep)
 {
     throw RubyExceptions.CreateTypeError("can't dump anonymous class " + RubyUtils.GetClassName(context, self));
 }
Exemple #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);
     }
 }
Exemple #11
0
 public static object SquareRoot(RubyContext /*!*/ context, BigDecimal /*!*/ self, object n)
 {
     throw RubyExceptions.CreateTypeError("wrong argument type " + RubyUtils.GetClassName(context, n) + " (expected Fixnum)");
 }
Exemple #12
0
 public static BigDecimal InducedFrom(RubyClass /*!*/ self, object value)
 {
     throw RubyExceptions.CreateTypeConversionError(RubyUtils.GetClassName(self.Context, value), self.Name);
 }
Exemple #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)));
     }
 }
Exemple #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)));
 }