예제 #1
0
        public static MutableString /*!*/ Inspect(RubyStruct /*!*/ self)
        {
            RubyContext context = self.Class.Context;

            using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) {
                // #<struct Struct::Foo name=nil, val=nil>
                MutableString str = MutableString.Create("#<struct ");
                str.Append(RubySites.Inspect(context, context.GetClassOf(self)));

                if (handle == null)
                {
                    return(str.Append(":...>"));
                }
                str.Append(' ');

                object[] data    = self.Values;
                var      members = self.GetNames();
                for (int i = 0; i < data.Length; i++)
                {
                    if (i != 0)
                    {
                        str.Append(", ");
                    }
                    str.Append(members[i]);
                    str.Append("=");
                    str.Append(RubySites.Inspect(context, data[i]));
                }
                str.Append('>');
                return(str);
            }
        }
예제 #2
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, Hash /*!*/ self)
        {
            using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) {
                if (handle == null)
                {
                    return(MutableString.Create("{...}"));
                }

                MutableString str   = MutableString.Create("{");
                bool          first = true;
                foreach (KeyValuePair <object, object> pair in self)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        str.Append(", ");
                    }
                    str.Append(RubySites.Inspect(context, BaseSymbolDictionary.ObjToNull(pair.Key)));
                    str.Append("=>");
                    str.Append(RubySites.Inspect(context, pair.Value));
                }
                str.Append('}');
                return(str);
            }
        }
예제 #3
0
        public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, Range /*!*/ self)
        {
            MutableString str = RubySites.Inspect(context, self.Begin);

            str.Append(self.ExcludeEnd ? "..." : "..");
            str.Append(RubySites.Inspect(context, self.End));
            return(str);
        }
예제 #4
0
        private void AppendInspect()
        {
            MutableString inspect = RubySites.Inspect(_context, _opts.Value);

            if (KernelOps.Tainted(_context, inspect))
            {
                _tainted = true;
            }

            AppendString(inspect);
        }
예제 #5
0
            public static MutableString Inspect(RubyContext /*!*/ context, FileSystemInfo /*!*/ self)
            {
                string result = String.Format(
                    "#<File::Stat dev={0}, ino={1}, mode={2}, nlink={3}, uid={4}, gid={5}, rdev={6}, size={7}, blksize={8}, blocks={9}, atime={10}, mtime={11}, ctime={12}",
                    RubySites.Inspect(context, DeviceId(self)), RubySites.Inspect(context, Inode(self)), RubySites.Inspect(context, Mode(self)),
                    RubySites.Inspect(context, NumberOfLinks(self)), RubySites.Inspect(context, UserId(self)), RubySites.Inspect(context, GroupId(self)),
                    RubySites.Inspect(context, DeviceId(self)), RubySites.Inspect(context, Size(self)), RubySites.Inspect(context, BlockSize(self)),
                    RubySites.Inspect(context, Blocks(self)), TimeOps.ToString(AccessTime(self)), TimeOps.ToString(ModifiedTime(self)),
                    TimeOps.ToString(CreateTime(self))
                    );

                return(MutableString.Create(result));
            }
예제 #6
0
 public static MutableString Inspect(RubyContext /*!*/ context, IDictionary <object, object> /*!*/ self)
 {
     using (IDisposable handle = RubyUtils.InfiniteInspectTracker.TrackObject(self)) {
         if (handle == null)
         {
             return(MutableString.Create("{...}"));
         }
         MutableString str = MutableString.CreateMutable();
         str.Append('{');
         foreach (KeyValuePair <object, object> pair in self)
         {
             if (str.Length != 1)
             {
                 str.Append(", ");
             }
             str.Append(RubySites.Inspect(context, BaseSymbolDictionary.ObjToNull(pair.Key)));
             str.Append("=>");
             str.Append(RubySites.Inspect(context, pair.Value));
         }
         str.Append('}');
         return(str);
     }
 }
예제 #7
0
 internal string /*!*/ GetDebugView()
 {
     return(RubySites.Inspect(RubyContext._Default, this).ToString());
 }