本文整理了Java中org.jruby.Ruby.getTrue
方法的一些代码示例,展示了Ruby.getTrue
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getTrue
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getTrue
[英]Returns the "true" instance from the instance pool.
[中]从实例池返回“true”实例。
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(name = "has_key?")
public IRubyObject hasKey(ThreadContext context, IRubyObject key) {
return this.table.containsKey(key) ? context.runtime.getTrue() : context.runtime.getFalse();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(name = "decode_json", meta = true)
public static IRubyObject decodeJson(ThreadContext context, IRubyObject recv, IRubyObject json) {
Ruby runtime = context.runtime;
RubyMessage ret = (RubyMessage) ((RubyClass) recv).newInstance(context, Block.NULL_BLOCK);
RubyModule jsonModule = runtime.getClassFromPath("JSON");
RubyHash opts = RubyHash.newHash(runtime);
opts.fastASet(runtime.newSymbol("symbolize_names"), runtime.getTrue());
IRubyObject[] args = new IRubyObject[] { Helpers.invoke(context, jsonModule, "parse", json, opts) };
ret.initialize(context, args);
return ret;
}
代码示例来源:origin: bazelbuild/bazel
return runtime.newFloat((Double) value);
case BOOL:
return (Boolean) value ? runtime.getTrue() : runtime.getFalse();
case BYTES: {
IRubyObject wrapped = runtime.newString(((ByteString) value).toStringUtf8());
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(name = "==")
public IRubyObject eq(ThreadContext context, IRubyObject _other) {
if (_other instanceof RubyHash)
return toHash(context).op_equal(context, _other);
RubyMap other = (RubyMap) _other;
if (this == other) return context.runtime.getTrue();
if (!typeCompatible(other) || this.table.size() != other.table.size())
return context.runtime.getFalse();
for (IRubyObject key : table.keySet()) {
if (! other.table.containsKey(key))
return context.runtime.getFalse();
if (! other.table.get(key).equals(table.get(key)))
return context.runtime.getFalse();
}
return context.runtime.getTrue();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(name = "==")
public IRubyObject eq(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (!(other instanceof RubyMessage))
return runtime.getFalse();
RubyMessage message = (RubyMessage) other;
if (descriptor != message.descriptor) {
return runtime.getFalse();
}
for (Descriptors.FieldDescriptor fdef : descriptor.getFields()) {
IRubyObject thisVal = getField(context, fdef);
IRubyObject thatVal = message.getField(context, fdef);
IRubyObject ret = thisVal.callMethod(context, "==", thatVal);
if (!ret.isTrue()) {
return runtime.getFalse();
}
}
return runtime.getTrue();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = {"odd?"}, compat = RUBY1_9)
public RubyBoolean odd_p(ThreadContext context) {
if(value%2 != 0) {
return context.runtime.getTrue();
}
return context.runtime.getFalse();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_obj_equal
*
* Will by default use identity equality to compare objects. This
* follows the Ruby semantics.
*
* The name of this method doesn't follow the convention because hierarchy problems
*/
@JRubyMethod(name = "==", compat = RUBY1_9)
public IRubyObject op_equal_19(ThreadContext context, IRubyObject obj) {
return this == obj ? context.runtime.getTrue() : context.runtime.getFalse();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = {"odd?"}, compat = RUBY1_9)
public RubyBoolean odd_p(ThreadContext context) {
if(value%2 != 0) {
return context.runtime.getTrue();
}
return context.runtime.getFalse();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_obj_equal
*
* Will by default use identity equality to compare objects. This
* follows the Ruby semantics.
*
* The name of this method doesn't follow the convention because hierarchy problems
*/
@JRubyMethod(name = "==", compat = RUBY1_9)
public IRubyObject op_equal_19(ThreadContext context, IRubyObject obj) {
return this == obj ? context.runtime.getTrue() : context.runtime.getFalse();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = {"even?"}, compat = RUBY1_9)
public RubyBoolean even_p(ThreadContext context) {
if(value%2 == 0) {
return context.runtime.getTrue();
}
return context.runtime.getFalse();
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "success?")
public IRubyObject success_p() {
final Ruby runtime = getRuntime();
final IRubyObject status = this.status;
if ( status.isNil() ) return runtime.getTrue();
if ( status == runtime.getTrue() || status == runtime.getFalse() ) return status;
if ( status.equals(RubyFixnum.zero(runtime)) ) return runtime.getTrue();
return runtime.getFalse();
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_hash_has_key
*
*/
@JRubyMethod(name = {"has_key?", "key?", "include?", "member?"}, required = 1)
public RubyBoolean has_key_p(ThreadContext context, IRubyObject key) {
Ruby runtime = context.runtime;
return internalGetEntry(key) == NO_ENTRY ? runtime.getFalse() : runtime.getTrue();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "valid_encoding?", compat = RUBY1_9)
public IRubyObject valid_encoding_p(ThreadContext context) {
Ruby runtime = context.runtime;
return scanForCodeRange() == CR_BROKEN ? runtime.getFalse() : runtime.getTrue();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_str_empty
*
*/
@JRubyMethod(name = "empty?")
public RubyBoolean empty_p(ThreadContext context) {
return isEmpty() ? context.runtime.getTrue() : context.runtime.getFalse();
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "success?")
public IRubyObject success_p() {
final Ruby runtime = getRuntime();
final IRubyObject status = this.status;
if ( status.isNil() ) return runtime.getTrue();
if ( status == runtime.getTrue() || status == runtime.getFalse() ) return status;
if ( status.equals(RubyFixnum.zero(runtime)) ) return runtime.getTrue();
return runtime.getFalse();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_str_empty
*
*/
@JRubyMethod(name = "empty?")
public RubyBoolean empty_p(ThreadContext context) {
return isEmpty() ? context.runtime.getTrue() : context.runtime.getFalse();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "ascii_only?", compat = RUBY1_9)
public IRubyObject ascii_only_p(ThreadContext context) {
Ruby runtime = context.runtime;
return scanForCodeRange() == CR_7BIT ? runtime.getTrue() : runtime.getFalse();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_8)
public static RubyBoolean system(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
return systemCommon(context, recv, args) == 0 ? runtime.getTrue() : runtime.getFalse();
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_hash_has_key
*
*/
@JRubyMethod(name = {"has_key?", "key?", "include?", "member?"}, required = 1)
public RubyBoolean has_key_p(ThreadContext context, IRubyObject key) {
Ruby runtime = context.runtime;
return internalGetEntry(key) == NO_ENTRY ? runtime.getFalse() : runtime.getTrue();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "eql?", compat = RUBY1_8)
public IRubyObject str_eql_p(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (other instanceof RubyString && value.equal(((RubyString)other).value)) return runtime.getTrue();
return runtime.getFalse();
}
内容来源于网络,如有侵权,请联系作者删除!