本文整理了Java中org.jruby.Ruby.is1_9
方法的一些代码示例,展示了Ruby.is1_9
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.is1_9
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:is1_9
暂无
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private boolean shouldMarshalEncoding(IRubyObject value) {
if (!runtime.is1_9()) return false;
if (!(value instanceof MarshalEncoding)) return false;
return ((MarshalEncoding) value).shouldMarshalEncoding();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyString getDefinedNot(Ruby runtime, RubyString definition) {
if (definition != null && runtime.is1_9()) {
definition = runtime.getDefinedMessage(DefinedMessage.METHOD);
}
return definition;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
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;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public LoadService create(Ruby runtime) {
if (runtime.is1_9()) {
return new OSGiLoadService19(runtime);
}
return new OSGiLoadService(runtime);
}
};
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@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;
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) throws IOException {
if (runtime.is1_9()) {
StringIO.createStringIOClass(runtime);
} else {
RubyStringIO.createStringIOClass(runtime);
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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);
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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);
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
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"));
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** 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");
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public final RubyString makeShared(Ruby runtime, int index, int len) {
return runtime.is1_9()
? makeShared19(runtime, getType(), index, len)
: makeShared(runtime, getType(), index, len);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject ioEncStr(IRubyObject str) {
str.setTaint(true);
if (getRuntime().is1_9()) ((EncodingCapable)str).setEncoding(getReadEncoding());
return str;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_hash_inspect
*
*/
@JRubyMethod(name = "inspect")
public IRubyObject inspect(ThreadContext context) {
if (context.runtime.is1_9()) return getOrCreateRubyHashMap().inspect19(context);
return getOrCreateRubyHashMap().inspect(context);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
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();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
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);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
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;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@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);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@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);
}
内容来源于网络,如有侵权,请联系作者删除!