private boolean shouldMarshalEncoding(IRubyObject value) { if (!runtime.is1_9()) return false; if (!(value instanceof MarshalEncoding)) return false; return ((MarshalEncoding) value).shouldMarshalEncoding(); }
public static RubyString getDefinedNot(Ruby runtime, RubyString definition) { if (definition != null && runtime.is1_9()) { definition = runtime.getDefinedMessage(DefinedMessage.METHOD); } return definition; }
public synchronized ThreadContext registerNewThread(RubyThread thread) { ThreadContext context = ThreadContext.newContext(runtime); localContext.set(new SoftReference(context)); context.setThread(thread); if (runtime.is1_9()) ThreadFiber.initRootFiber(context); // may be overwritten by fiber return context; }
public LoadService create(Ruby runtime) { if (runtime.is1_9()) { return new OSGiLoadService19(runtime); } return new OSGiLoadService(runtime); } };
@Override public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { RubyString definition = runtime.getDefinedMessage(DefinedMessage.LOCAL_VARIABLE); if (!context.runtime.is1_9()) { definition = runtime.getDefinedMessage(DefinedMessage.LOCAL_VARIABLE_IN_BLOCK); } return definition; } }
public void load(Ruby runtime, boolean wrap) throws IOException { if (runtime.is1_9()) { StringIO.createStringIOClass(runtime); } else { RubyStringIO.createStringIOClass(runtime); } } }
@Override public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { if (!context.runtime.is1_9()) { return super.definition(runtime, context, self, aBlock); } else { return runtime.getDefinedMessage(DefinedMessage.EXPRESSION); } } }
@Override public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { if (!context.runtime.is1_9()) { return super.definition(runtime, context, self, aBlock); } else { return runtime.getDefinedMessage(DefinedMessage.EXPRESSION); } } }
static void recacheBuiltinMethods(Ruby runtime) { RubyModule objectClass = runtime.getBasicObject(); if (runtime.is1_9()) { // method_missing is in Kernel in 1.9 runtime.setDefaultMethodMissing(objectClass.searchMethod("method_missing")); } }
/** nil_inspect * */ @JRubyMethod(name = "inspect") public static RubyString inspect(IRubyObject recv) { Ruby runtime = recv.getRuntime(); if (runtime.is1_9()) { return RubyString.newUSASCIIString(runtime, "nil"); } else { return RubyString.newString(runtime, "nil"); } }
public final RubyString makeShared(Ruby runtime, int index, int len) { return runtime.is1_9() ? makeShared19(runtime, getType(), index, len) : makeShared(runtime, getType(), index, len); }
private IRubyObject ioEncStr(IRubyObject str) { str.setTaint(true); if (getRuntime().is1_9()) ((EncodingCapable)str).setEncoding(getReadEncoding()); return str; }
/** rb_hash_inspect * */ @JRubyMethod(name = "inspect") public IRubyObject inspect(ThreadContext context) { if (context.runtime.is1_9()) return getOrCreateRubyHashMap().inspect19(context); return getOrCreateRubyHashMap().inspect(context); }
public static RubyString get_path(ThreadContext context, IRubyObject path) { if (path instanceof RubyString) { return (RubyString)path; } if (context.runtime.is1_9()) { if (path.respondsTo("to_path")) path = path.callMethod(context, "to_path"); return filePathConvert(context, path.convertToString()); } return path.convertToString(); }
@JRubyMethod(name = {"[]", "slice"}, compat = RUBY1_8) public IRubyObject aref(IRubyObject arg0, IRubyObject arg1) { assert !arg0.getRuntime().is1_9(); if (arg0 instanceof RubySymbol) throw getRuntime().newTypeError("Symbol as array index"); return arefCommon(arg0, arg1); }
public static RubyArray argsCat(IRubyObject first, IRubyObject second) { Ruby runtime = first.getRuntime(); IRubyObject secondArgs; if (runtime.is1_9()) { secondArgs = Helpers.splatValue19(second); } else { secondArgs = Helpers.splatValue(second); } return ((RubyArray) Helpers.ensureRubyArray(runtime, first).dup()).concat(secondArgs); }
public static IRubyObject srandCommon(ThreadContext context, IRubyObject recv, IRubyObject newSeed) { RandomType defaultRand = getDefaultRand(context); IRubyObject previousSeed = defaultRand.getSeed(); defaultRand = new RandomType(newSeed); context.runtime.setDefaultRand(defaultRand); if (context.runtime.is1_9()) { ((RubyRandom) (context.runtime.getRandomClass()) .getConstant("DEFAULT")).setRandomType(defaultRand); } return previousSeed; }
@Override public final int compareTo(IRubyObject other) { Ruby runtime = getRuntime(); if (other instanceof RubyString) { RubyString otherString = (RubyString)other; return runtime.is1_9() ? op_cmp19(otherString) : op_cmp(otherString); } return (int)op_cmpCommon(runtime.getCurrentContext(), other).convertToInteger().getLongValue(); }
@JRubyMethod public RubyString to_s(IRubyObject arg0) { int base = num2int(arg0); if (base < 2 || base > 36) { throw getRuntime().newArgumentError("illegal radix " + base); } ByteList bl = ConvertBytes.longToByteList(value, base); if (getRuntime().is1_9()) bl.setEncoding(USASCIIEncoding.INSTANCE); return getRuntime().newString(bl); }
@JRubyMethod public RubyString to_s(IRubyObject arg0) { int base = num2int(arg0); if (base < 2 || base > 36) { throw getRuntime().newArgumentError("illegal radix " + base); } ByteList bl = ConvertBytes.longToByteList(value, base); if (getRuntime().is1_9()) bl.setEncoding(USASCIIEncoding.INSTANCE); return getRuntime().newString(bl); }