Exemplo n.º 1
0
        public static MutableString /*!*/ ToS(RubyContext /*!*/ context, Range /*!*/ self)
        {
            MutableString str = RubySites.ToS(context, self.Begin);

            str.Append(self.ExcludeEnd ? "..." : "..");
            str.Append(RubySites.ToS(context, self.End));
            return(str);
        }
Exemplo n.º 2
0
        public static MutableString /*!*/ ToPrintedString(RubyContext /*!*/ context, object obj)
        {
            IDictionary <object, object> hash;
            List <object> list;
            MutableString str;

            if ((list = obj as List <object>) != null)
            {
                return(IListOps.Join(context, list, Environment.NewLine));
            }
            else if ((hash = obj as IDictionary <object, object>) != null)
            {
                return(IDictionaryOps.ToString(context, hash));
            }
            else if (obj == null)
            {
                return(MutableString.Create("nil"));
            }
            else if (obj is bool)
            {
                return(MutableString.Create((bool)obj ? "true" : "false"));
            }
            else if (obj is double)
            {
                var result = MutableString.Create(obj.ToString());
                if ((double)(int)(double)obj == (double)obj)
                {
                    result.Append(".0");
                }
                return(result);
            }
            else if ((str = obj as MutableString) != null)
            {
                return(str);
            }
            else
            {
                return(RubySites.ToS(context, obj));
            }
        }