public static object MethodMissing(RubyScope /*!*/ scope, BlockParam block, string /*!*/ self, [NotNull] RubySymbol /*!*/ name, params object[] /*!*/ args) { if (name.EndsWith('=') || name.EndsWith('!')) { throw RubyExceptions.CreateTypeError("Mutating method `{0}' called for an immutable string (System::String)", name); } // TODO: forward to MutableString until we implement the methods here: return(KernelOps.SendMessageOpt(scope, block, ToStr(self), name.ToString(), args)); }
public string /*!*/ GetString() { return(_string ?? (_string = _symbol.ToString())); }
public static MutableString /*!*/ Inspect(RubyContext /*!*/ context, RubySymbol /*!*/ self) { var str = self.ToString(); bool allowMultiByteCharacters = context.RubyOptions.Compatibility >= RubyCompatibility.Ruby19 || context.KCode != null; var result = self.String.Clone(); // simple cases: if ( Tokenizer.IsMethodName(str, allowMultiByteCharacters) || Tokenizer.IsConstantName(str, allowMultiByteCharacters) || Tokenizer.IsInstanceVariableName(str, allowMultiByteCharacters) || Tokenizer.IsClassVariableName(str, allowMultiByteCharacters) || Tokenizer.IsGlobalVariableName(str, allowMultiByteCharacters) ) { result.Insert(0, ':'); } else { // TODO: this is neither efficient nor complete. // Any string that parses as 'sym' should not be quoted. switch (str) { case null: // Ruby doesn't allow empty symbols, we can get one from outside though: return(MutableString.CreateAscii(":\"\"")); case "!": case "|": case "^": case "&": case "<=>": case "==": case "===": case "=~": case "!=": case "!~": case ">": case ">=": case "<": case "<=": case "<<": case ">>": case "+": case "-": case "*": case "/": case "%": case "**": case "~": case "+@": case "-@": case "[]": case "[]=": case "`": case "$!": case "$@": case "$,": case "$;": case "$/": case "$\\": case "$*": case "$$": case "$?": case "$=": case "$:": case "$\"": case "$<": case "$>": case "$.": case "$~": case "$&": case "$`": case "$'": case "$+": result.Insert(0, ':'); break; default: result.Insert(0, ":\"").Append('"'); break; } } if (context.RuntimeId != self.RuntimeId) { result.Append(" @").Append(self.RuntimeId.ToString(CultureInfo.InvariantCulture)); } return(result); }
public static Proc /*!*/ ToProc(RubyScope /*!*/ scope, RubySymbol /*!*/ self) { return(Proc.CreateMethodInvoker(scope, self.ToString())); }
public static string /*!*/ ToClrString(RubySymbol /*!*/ self) { return(self.ToString()); }
public static object SetValue(RubyStruct /*!*/ self, [NotNull] RubySymbol /*!*/ name, object value) { return(self[name.ToString()] = value); }
public static object MethodMissing(RubyContext /*!*/ context, object /*!*/ self, [NotNull] RubySymbol /*!*/ name, params object[] /*!*/ args) { throw RubyExceptions.CreateMethodMissing(context, self, name.ToString()); }