Refine search
@JRubyMethod(name = "has_key?") public IRubyObject hasKey(ThreadContext context, IRubyObject key) { return this.table.containsKey(key) ? context.runtime.getTrue() : context.runtime.getFalse(); }
@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; }
@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(); }
@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(); }
@JRubyMethod(name = {"odd?"}, compat = RUBY1_9) public RubyBoolean odd_p(ThreadContext context) { if(value%2 != 0) { return context.runtime.getTrue(); } return context.runtime.getFalse(); }
/** 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(); }
@JRubyMethod(name = {"odd?"}, compat = RUBY1_9) public RubyBoolean odd_p(ThreadContext context) { if(value%2 != 0) { return context.runtime.getTrue(); } return context.runtime.getFalse(); }
/** 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(); }
@JRubyMethod(name = {"even?"}, compat = RUBY1_9) public RubyBoolean even_p(ThreadContext context) { if(value%2 == 0) { return context.runtime.getTrue(); } return context.runtime.getFalse(); }
@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(); }
/** 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(); }
@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(); }
/** rb_str_empty * */ @JRubyMethod(name = "empty?") public RubyBoolean empty_p(ThreadContext context) { return isEmpty() ? context.runtime.getTrue() : context.runtime.getFalse(); }
@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(); }
/** rb_str_empty * */ @JRubyMethod(name = "empty?") public RubyBoolean empty_p(ThreadContext context) { return isEmpty() ? context.runtime.getTrue() : context.runtime.getFalse(); }
@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(); }
@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(); }
/** 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(); }
@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(); }