/** nil_to_s * */ @JRubyMethod(name = "to_s") public static RubyString to_s(ThreadContext context, IRubyObject recv) { return RubyString.newEmptyString(context.runtime); }
/** nil_to_s * */ @JRubyMethod(name = "to_s") public static RubyString to_s(ThreadContext context, IRubyObject recv) { return RubyString.newEmptyString(context.runtime); }
/** nil_to_s * */ @JRubyMethod public static RubyString to_s(ThreadContext context, IRubyObject recv) { return RubyString.newEmptyString(context.runtime); }
public static IRubyObject to_s(Ruby runtime, Object dataStruct) { if (dataStruct != null) { final String stringValue = dataStruct.toString(); if ( stringValue == null ) return runtime.getNil(); return RubyString.newUnicodeString(runtime, stringValue); } return RubyString.newEmptyString(runtime); }
@JRubyMethod(optional = 3, visibility = Visibility.PRIVATE) @Override public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) { if (args.length == 0) { args = new IRubyObject[] {RubyString.newEmptyString(context.runtime)}; } return initializeCommon(context, args); }
@JRubyMethod public static IRubyObject message(final ThreadContext context, final IRubyObject self) { java.lang.Throwable throwable = unwrapIfJavaObject(self); final String msg = throwable.getLocalizedMessage(); // does getMessage return msg == null ? RubyString.newEmptyString(context.runtime) : RubyString.newString(context.runtime, msg); }
@JRubyMethod public IRubyObject addr(ThreadContext context) { final Ruby runtime = context.runtime; return runtime.newArray( runtime.newString("AF_UNIX"), RubyString.newEmptyString(runtime) ); }
private RubyEnumerator(Ruby runtime, RubyClass type) { super(runtime, type); object = runtime.getNil(); initialize(runtime, runtime.getNil(), RubyString.newEmptyString(runtime), IRubyObject.NULL_ARRAY); }
@Override public RubyString to_s(ThreadContext context) { if ( message.isNil() ) { return RubyString.newEmptyString(context.runtime); } if ( tag == null ) return message.asString(); final RubyString str = message.asString(); return str.op_format(context, RubyArray.newArray(context.runtime, tag)); }
@JRubyMethod(name = "slice!", reads = BACKREF, writes = BACKREF, compat = RUBY1_9) public IRubyObject slice_bang19(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { IRubyObject result = op_aref19(context, arg0, arg1); if (result.isNil()) { modifyCheck(); // keep cr ? } else { op_aset19(context, arg0, arg1, RubyString.newEmptyString(context.runtime)); } return result; }
public static IRubyObject checkStringType(IRubyObject self) { IRubyObject str = TypeConverter.convertToTypeWithCheck(self, getRuntime(self).getString(), "to_str"); if(!str.isNil() && !(str instanceof RubyString)) { str = RubyString.newEmptyString(getRuntime(self)); } return str; }
@JRubyMethod public IRubyObject peeraddr(ThreadContext context) { final Ruby runtime = context.runtime; final String _path = getUnixRemoteSocket().path(); final RubyString path = (_path == null) ? RubyString.newEmptyString(runtime) : runtime.newString(_path); return runtime.newArray( runtime.newString("AF_UNIX"), path ); }
@JRubyMethod public IRubyObject peeraddr(ThreadContext context) { final Ruby runtime = context.runtime; final String _path = getUnixRemoteSocket().path(); final RubyString path = (_path == null) ? RubyString.newEmptyString(runtime) : runtime.newString(_path); return runtime.newArray( runtime.newString("AF_UNIX"), path ); }
private IRubyObject inspect1() { final Ruby runtime = getRuntime(); if (pos == 0) return RubyString.newEmptyString(runtime); if (pos > INSPECT_LENGTH) { return RubyString.newStringNoCopy(runtime, DOT_BYTES). append(str.substr(runtime, pos - INSPECT_LENGTH, INSPECT_LENGTH)).inspect(); } return str.substr(runtime, 0, pos).inspect(); }
@JRubyMethod(name = "chop") public IRubyObject chop(ThreadContext context) { Ruby runtime = context.runtime; if (value.getRealSize() == 0) return newEmptyString(runtime, getMetaClass(), value.getEncoding()).infectBy(this); return makeShared(runtime, 0, StringSupport.choppedLength(this)); }
private IRubyObject inspect1() { if (pos == 0) return RubyString.newEmptyString(getRuntime()); if (pos > INSPECT_LENGTH) { return RubyString.newStringNoCopy(getRuntime(), "...".getBytes()). append(str.substr(getRuntime(), pos - INSPECT_LENGTH, INSPECT_LENGTH)).inspect(); } else { return str.substr(getRuntime(), 0, pos).inspect(); } }
@JRubyMethod(name = "rest") public IRubyObject rest(ThreadContext context) { check(); ByteList value = str.getByteList(); if (pos >= value.getRealSize()) { return RubyString.newEmptyString(context.runtime).infectBy(str); } return extractRange(context.runtime, pos, value.getRealSize()); }
/** match_to_s * */ @JRubyMethod @Override public IRubyObject to_s() { check(); IRubyObject ss = RubyRegexp.last_match(this); if (ss.isNil()) ss = RubyString.newEmptyString(getRuntime()); if (isTaint()) ss.setTaint(true); return ss; }
@JRubyMethod(name = {"succ", "next"}) public IRubyObject succ(ThreadContext context) { Ruby runtime = context.runtime; final RubyString str; if (value.getRealSize() > 0) { str = new RubyString(runtime, getMetaClass(), StringSupport.succCommon(runtime, value)); // TODO: rescan code range ? } else { str = newEmptyString(runtime, getType(), value.getEncoding()); } return str.infectBy(this); }
@JRubyMethod(name = "peek", required = 1) public IRubyObject peek(ThreadContext context, IRubyObject length) { check(); int len = RubyNumeric.num2int(length); if (len < 0) { throw context.runtime.newArgumentError("negative string size (or size too big)"); } ByteList value = str.getByteList(); if (pos >= value.getRealSize()) return RubyString.newEmptyString(context.runtime).infectBy(str); if (pos + len > value.getRealSize()) len = value.getRealSize() - pos; return extractBegLen(context.runtime, pos, len); }