private static RubyRegex /*!*/ Union(ConversionStorage <MutableString> /*!*/ stringCast, ICollection /*!*/ objs) { if (objs.Count == 0) { return(new RubyRegex(MutableString.CreateAscii("(?!)"), RubyRegexOptions.NONE)); } MutableString result = MutableString.CreateMutable(RubyEncoding.Binary); int i = 0; foreach (var obj in objs) { if (i > 0) { result.Append('|'); } // TODO: to_regexp RubyRegex regex = obj as RubyRegex; if (regex != null) { if (objs.Count == 1) { return(regex); } regex.AppendTo(result); } else { result.Append(RubyRegex.Escape(Protocols.CastToString(stringCast, obj))); } i++; } return(new RubyRegex(result, RubyRegexOptions.NONE)); }
public static RubyRegex /*!*/ Union(ConversionStorage <MutableString> /*!*/ stringCast, RubyClass /*!*/ self, params object[] /*!*/ strings) { if (strings.Length == 0) { return(new RubyRegex(MutableString.CreateAscii("(?!)"), RubyRegexOptions.NONE)); } MutableString result = MutableString.CreateMutable(RubyEncoding.Binary); for (int i = 0; i < strings.Length; i++) { if (i > 0) { result.Append('|'); } RubyRegex regex = strings[i] as RubyRegex; if (regex != null) { if (strings.Length == 1) { return(regex); } regex.AppendTo(result); } else { result.Append(RubyRegex.Escape(Protocols.CastToString(stringCast, strings[i]))); } } // TODO: //RubyClass regexClass = RubyUtils.GetExecutionContext(context).GetClass(typeof(RubyRegex)); //return NewCallSite3.Invoke(context, regexClass, result, null, null); return(new RubyRegex(result, RubyRegexOptions.NONE)); }