Beispiel #1
0
 public static RubyRegex /*!*/ Reinitialize(RubyRegex /*!*/ self, [NotNull] RubyRegex /*!*/ other)
 {
     self.Set(other.Pattern, other.Options);
     return(self);
 }
Beispiel #2
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.Pattern, 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);
            }
Beispiel #3
0
 public static RubyRegex /*!*/ Reinitialize(RubyRegex /*!*/ self,
                                            [DefaultProtocol, NotNull] MutableString /*!*/ pattern, [Optional] bool ignoreCase, [DefaultProtocol, Optional] MutableString encoding)
 {
     self.Set(pattern, MakeOptions(ignoreCase, encoding));
     return(self);
 }