private RubyString calculateAnonymousRubyName() { Ruby runtime = getRuntime(); RubyString anonBase = runtime.newString("#<"); // anonymous classes get the #<Class:0xdeadbeef> format anonBase.append(metaClass.getRealClass().rubyName()).append(runtime.newString(":0x")); anonBase.append(runtime.newString(Integer.toHexString(System.identityHashCode(this)))).append(runtime.newString(">")); return anonBase; }
private RubyString calculateAnonymousRubyName() { Ruby runtime = getRuntime(); RubyString anonBase = runtime.newString("#<"); // anonymous classes get the #<Class:0xdeadbeef> format anonBase.append(metaClass.getRealClass().rubyName()).append(runtime.newString(":0x")); anonBase.append(runtime.newString(Integer.toHexString(System.identityHashCode(this)))).append(runtime.newString(">")); return anonBase; }
@JRubyMethod(name = {"concat", "<<"}, required = 1) public IRubyObject concat(IRubyObject obj) { check(); str.append(obj); // append will call convertToString() return this; }
@JRubyMethod(name = {"concat", "<<"}, required = 1) public IRubyObject concat(IRubyObject obj) { check(); str.append(obj.convertToString()); return this; }
@JRubyMethod(name = {"concat", "<<"}, required = 1) public IRubyObject concat(IRubyObject obj) { check(); str.append(obj.convertToString()); return this; }
@Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { RubyString newString = context.runtime.newString(); for (Operand p: pieces) { RubyBasicObject piece = (RubyBasicObject) p.retrieve(context, self, currDynScope, temp); newString.append((piece instanceof RubyString) ? (RubyString) piece : piece.to_s()); } return self.callMethod(context, "`", newString); }
private RubyString to_s(final Ruby runtime) { RubyString i1 = begin.asString().strDup(runtime); RubyString i2 = end.asString(); i1.cat(DOTDOTDOT, 0, isExclusive ? 3 : 2); i1.append(i2); i1.infectBy(i2); i1.infectBy(this); return i1; }
private RubyString to_s(final Ruby runtime) { RubyString i1 = begin.asString().strDup(runtime); RubyString i2 = end.asString(); i1.cat(DOTDOTDOT, 0, isExclusive ? 3 : 2); i1.append(i2); i1.infectBy(i2); i1.infectBy(this); return i1; }
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 = "inspect") public RubyString inspect(final ThreadContext context) { RubyString i1 = inspectValue(context, begin).strDup(context.runtime); RubyString i2 = inspectValue(context, end); i1.cat(DOTDOTDOT, 0, isExclusive ? 3 : 2); i1.append(i2); i1.infectBy(i2); i1.infectBy(this); return i1; }
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 = "inspect") public RubyString inspect(final ThreadContext context) { RubyString i1 = inspectValue(context, begin).strDup(context.runtime); RubyString i2 = inspectValue(context, end); i1.cat(DOTDOTDOT, 0, isExclusive ? 3 : 2); i1.append(i2); i1.infectBy(i2); i1.infectBy(this); return i1; }
@JRubyMethod(name = "insert", compat = RUBY1_8) public IRubyObject insert(ThreadContext context, IRubyObject indexArg, IRubyObject stringArg) { assert !context.runtime.is1_9(); RubyString str = stringArg.convertToString(); int index = RubyNumeric.num2int(indexArg); if (index == -1) return append(stringArg); if (index < 0) index++; replaceInternal(checkIndex(index, value.getRealSize()), 0, str); return this; }
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(); }
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(); } }