Пример #1
0
            private void WriteRegex(RubyRegex /*!*/ value)
            {
                SubclassData instanceWriter = new SubclassData(this, value, typeof(RubyRegex));

                _writer.Write((byte)'/');
                WriteStringValue(value.GetPattern());
                _writer.Write((byte)value.Options);
            }
Пример #2
0
        public static MutableString /*!*/ Inspect(RubyRegex /*!*/ self)
        {
            MutableString result = MutableString.CreateMutable();

            result.Append('/');
            AppendEscapeForwardSlash(result, self.GetPattern());
            result.Append('/');
            AppendOptionString(result, self.Options, true, true);
            return(result);
        }
Пример #3
0
        private static MutableString /*!*/ Append(RubyRegex /*!*/ self, MutableString /*!*/ result)
        {
            Assert.NotNull(self, result);

            result.Append("(?");
            if (AppendOptionString(result, self.Options, true, false) < 3)
            {
                result.Append('-');
            }
            AppendOptionString(result, self.Options, false, false);
            result.Append(':');
            AppendEscapeForwardSlash(result, self.GetPattern());
            result.Append(')');
            return(result);
        }
Пример #4
0
 public static RubyRegex /*!*/ Reinitialize(RubyRegex /*!*/ self, [NotNull] RubyRegex /*!*/ other)
 {
     self.Set(other.GetPattern(), other.Options);
     return(self);
 }
Пример #5
0
 public static MutableString /*!*/ Source(RubyRegex /*!*/ self)
 {
     return(self.GetPattern());
 }
Пример #6
0
            private object /*!*/ ReadUserClass()
            {
                object obj      = UnmarshalNewObject();
                bool   loaded   = false;
                int    typeFlag = _reader.ReadByte();

                switch (typeFlag)
                {
                case '"':
                    MutableString msc = (obj as MutableString);
                    if (msc != null)
                    {
                        msc.Replace(0, msc.Length, ReadString());
                        loaded = true;
                    }
                    break;

                case '/':
                    RubyRegex rsc = (obj as RubyRegex);
                    if (rsc != null)
                    {
                        RubyRegex regex = ReadRegex();
                        rsc.Set(regex.GetPattern(), regex.Options);
                        loaded = true;
                    }
                    break;

                case '[':
                    RubyArray asc = (obj as RubyArray);
                    if (asc != null)
                    {
                        asc.AddRange(ReadArray());
                        loaded = true;
                    }
                    break;

                case '{':
                case '}':
                    Hash hsc = (obj as Hash);
                    if (hsc != null)
                    {
                        Hash hash = ReadHash(typeFlag);
                        hsc.DefaultProc  = hash.DefaultProc;
                        hsc.DefaultValue = hash.DefaultValue;
                        foreach (var pair in hash)
                        {
                            hsc.Add(pair.Key, pair.Value);
                        }
                        loaded = true;
                    }
                    break;

                default:
                    break;
                }
                if (!loaded)
                {
                    throw RubyExceptions.CreateArgumentError("incompatible base type");
                }
                return(obj);
            }