private String layoutInspect() { ThreadContext context = getRuntime().getCurrentContext(); StringBuilder sb = new StringBuilder(); for (Descriptors.FieldDescriptor fdef : descriptor.getFields()) { sb.append(Utils.unescapeIdentifier(fdef.getName())); sb.append(": "); sb.append(getField(context, fdef).inspect()); sb.append(", "); } return sb.substring(0, sb.length() - 2); }
@JRubyMethod(name = "inspect") @Override public IRubyObject inspect() { RubyModule rubyClass = getMetaClass(); StringBuilder buffer = new StringBuilder("#<"); buffer.append(rubyClass.getName()).append(": ").append(success.inspect().toString()); buffer.append(", ").append(failed.inspect().toString()).append(">"); return getRuntime().newString(buffer.toString()); } }
@JRubyMethod(name = "inspect") @Override public IRubyObject inspect() { RubyModule rubyClass = getMetaClass(); StringBuilder buffer = new StringBuilder("#<"); buffer.append(rubyClass.getName()).append(": ").append(success.inspect().toString()); buffer.append(", ").append(failed.inspect().toString()).append(">"); return getRuntime().newString(buffer.toString()); } }
@JRubyMethod public static IRubyObject inspect(IRubyObject recv) { if (recv instanceof RubyBasicObject) { return ((RubyBasicObject) recv).hashyInspect(); } return recv.inspect(); }
@JRubyMethod public static IRubyObject inspect(IRubyObject recv) { if (recv instanceof RubyBasicObject) { return ((RubyBasicObject) recv).hashyInspect(); } return recv.inspect(); }
@JRubyMethod public IRubyObject inspect(ThreadContext context) { return to_s(context).inspect(); }
private synchronized IRubyObject lookupAndCacheValue(IRubyObject obj) { IRubyObject value = enums.fastARef(obj); if (value.isNil() || !(value instanceof RubyInteger)) { throw obj.getRuntime().newArgumentError("invalid enum value, " + obj.inspect()); } IdentityHashMap<RubySymbol, RubyInteger> s2v = new IdentityHashMap<RubySymbol, RubyInteger>(symbolToValue); s2v.put((RubySymbol) obj, (RubyInteger) value); this.symbolToValue = new IdentityHashMap<RubySymbol, RubyInteger>(s2v); return value; } }
private synchronized IRubyObject lookupAndCacheValue(IRubyObject obj) { IRubyObject value = enums.fastARef(obj); if (value.isNil() || !(value instanceof RubyInteger)) { throw obj.getRuntime().newArgumentError("invalid enum value, " + obj.inspect()); } IdentityHashMap<RubySymbol, RubyInteger> s2v = new IdentityHashMap<RubySymbol, RubyInteger>(symbolToValue); s2v.put((RubySymbol) obj, (RubyInteger) value); this.symbolToValue = new IdentityHashMap<RubySymbol, RubyInteger>(s2v); return value; } }
private synchronized IRubyObject lookupAndCacheValue(ThreadContext context, IRubyObject obj) { IRubyObject value = enums instanceof Enums ? ((Enums)enums).mapSymbol(context, obj) : ((RubyHash)enums).fastARef(obj); if (value.isNil() || !(value instanceof RubyInteger)) { throw obj.getRuntime().newArgumentError("invalid enum value, " + obj.inspect()); } IdentityHashMap<RubySymbol, RubyInteger> s2v = new IdentityHashMap<RubySymbol, RubyInteger>(symbolToValue); s2v.put((RubySymbol) obj, (RubyInteger) value); this.symbolToValue = new IdentityHashMap<RubySymbol, RubyInteger>(s2v); return value; } }
/** coerce_failed * */ protected final void coerceFailed(ThreadContext context, IRubyObject other) { throw context.runtime.newTypeError(String.format("%s can't be coerced into %s", (other.isSpecialConst() ? other.inspect() : other.getMetaClass().getName()), getMetaClass())); }
/** coerce_failed * */ protected final void coerceFailed(ThreadContext context, IRubyObject other) { throw context.runtime.newTypeError(String.format("%s can't be coerced into %s", (other.isSpecialConst() ? other.inspect() : other.getMetaClass().getName()), getMetaClass())); }
@JRubyMethod public IRubyObject fetch(ThreadContext context, IRubyObject key, Block block) { Ruby runtime = context.runtime; IRubyObject value = op_aref(key); if (value.isNil()) { if (block.isGiven()) return block.yield(context, key); throw runtime.newKeyError("key not found: " + key.inspect(), this, key); } return value; }
@JRubyMethod public IRubyObject fetch(ThreadContext context, IRubyObject key, Block block) { Ruby runtime = context.runtime; IRubyObject value = op_aref(key); if (value.isNil()) { if (block.isGiven()) return block.yield(context, key); throw runtime.newKeyError("key not found: " + key.inspect(), this, key); } return value; }
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(); }
public static int intValue(IRubyObject obj, RubyHash enums) { if (obj instanceof RubyInteger) { return (int) ((RubyInteger) obj).getLongValue(); } else if (obj instanceof RubySymbol) { IRubyObject value = enums.fastARef(obj); if (value.isNil()) { throw obj.getRuntime().newArgumentError("invalid enum value, " + obj.inspect()); } return (int) longValue(value); } else { return (int) longValue(obj); } }
private IRubyObject inspect2() { if (pos >= str.getByteList().getRealSize()) return RubyString.newEmptyString(getRuntime()); int len = str.getByteList().getRealSize() - pos; if (len > INSPECT_LENGTH) { return ((RubyString)str.substr(getRuntime(), pos, INSPECT_LENGTH)).cat("...".getBytes()).inspect(); } else { return str.substr(getRuntime(), pos, len).inspect(); } }
/** rb_cmperr * */ public static IRubyObject cmperr(IRubyObject recv, IRubyObject other) { IRubyObject target; if (other.isImmediate() || !(other.isNil() || other.isTrue() || other == recv.getRuntime().getFalse())) { target = other.inspect(); } else { target = other.getType(); } throw recv.getRuntime().newArgumentError("comparison of " + recv.getType() + " with " + target + " failed"); }
private IRubyObject inspect2() { final Ruby runtime = getRuntime(); if (pos >= str.getByteList().getRealSize()) return RubyString.newEmptyString(runtime); int len = str.getByteList().getRealSize() - pos; if (len > INSPECT_LENGTH) { return ((RubyString) str.substr(runtime, pos, INSPECT_LENGTH)).cat(DOT_BYTES).inspect(); } return str.substr(runtime, pos, len).inspect(); }
private IRubyObject inspect2() { final Ruby runtime = getRuntime(); if (pos >= str.getByteList().getRealSize()) return RubyString.newEmptyString(runtime); int len = str.getByteList().getRealSize() - pos; if (len > INSPECT_LENGTH) { return ((RubyString) str.substr(runtime, pos, INSPECT_LENGTH)).cat(DOT_BYTES).inspect(); } return str.substr(runtime, pos, len).inspect(); }