@Deprecated public IRubyObject each_pair(final ThreadContext context, final Block block) { return block.isGiven() ? each_pairCommon(context, block) : enumeratorizeWithSize(context, this, "each_pair", enumSizeFn()); }
@JRubyMethod public IRubyObject keep_if(final ThreadContext context, final Block block) { if (block.isGiven()) { keep_ifCommon(context, block); return this; } return enumeratorizeWithSize(context, this, "keep_if", enumSizeFn()); }
@JRubyMethod public IRubyObject each_value(final ThreadContext context, final Block block) { return block.isGiven() ? each_valueCommon(context, block) : enumeratorizeWithSize(context, this, "each_value", enumSizeFn()); }
@JRubyMethod public IRubyObject delete_if(final ThreadContext context, final Block block) { return block.isGiven() ? delete_ifInternal(context, block) : enumeratorizeWithSize(context, this, "delete_if", enumSizeFn()); }
@JRubyMethod(name = "select!") public IRubyObject select_bang(final ThreadContext context, final Block block) { if (block.isGiven()) return keep_ifCommon(context, block) ? this : context.nil; return enumeratorizeWithSize(context, this, "select!", enumSizeFn()); }
@JRubyMethod(name = "select!") public IRubyObject select_bang(final ThreadContext context, final Block block) { if (block.isGiven()) return keep_ifCommon(context, block) ? this : context.nil; return enumeratorizeWithSize(context, this, "select!", enumSizeFn()); }
@JRubyMethod public IRubyObject keep_if(final ThreadContext context, final Block block) { if (block.isGiven()) { keep_ifCommon(context, block); return this; } return enumeratorizeWithSize(context, this, "keep_if", enumSizeFn()); }
@JRubyMethod public IRubyObject reject(final ThreadContext context, final Block block) { return block.isGiven() ? rejectInternal(context, block) : enumeratorizeWithSize(context, this, "reject", enumSizeFn()); }
@JRubyMethod(name = {"each", "each_pair"}) public IRubyObject each(final ThreadContext context, final Block block) { return block.isGiven() ? each_pairCommon(context, block) : enumeratorizeWithSize(context, this, "each", enumSizeFn()); }
@JRubyMethod public IRubyObject each_key(final ThreadContext context, final Block block) { return block.isGiven() ? each_keyCommon(context, block) : enumeratorizeWithSize(context, this, "each_key", enumSizeFn()); }
@JRubyMethod public IRubyObject reject(final ThreadContext context, final Block block) { return block.isGiven() ? rejectInternal(context, block) : enumeratorizeWithSize(context, this, "reject", enumSizeFn()); }
@JRubyMethod(name = "reject!") public IRubyObject reject_bang(final ThreadContext context, final Block block) { return block.isGiven() ? reject_bangInternal(context, block) : enumeratorizeWithSize(context, this, "reject!", enumSizeFn()); }
@JRubyMethod(name = "transform_keys!") public IRubyObject transform_keys_bang(final ThreadContext context, final Block block) { if (block.isGiven()) { testFrozen("Hash"); RubyArray keys = keys(context); Arrays.stream(keys.toJavaArrayMaybeUnsafe()).forEach((key) -> { op_aset(context, block.yield(context, key), delete(context, key)); }); return this; } return enumeratorizeWithSize(context, this, "transform_keys!", enumSizeFn()); }
@JRubyMethod(name = "transform_keys!") public IRubyObject transform_keys_bang(final ThreadContext context, final Block block) { if (block.isGiven()) { testFrozen("Hash"); RubyArray keys = keys(context); Arrays.stream(keys.toJavaArrayMaybeUnsafe()).forEach((key) -> { op_aset(context, block.yield(context, key), delete(context, key)); }); return this; } return enumeratorizeWithSize(context, this, "transform_keys!", enumSizeFn()); }
@JRubyMethod(name = "transform_values!") public IRubyObject transform_values_bang(final ThreadContext context, final Block block) { if (block.isGiven()) { testFrozen("Hash"); TransformValuesVisitor tvf = new TransformValuesVisitor(); iteratorVisitAll(context, tvf, block); return this; } return enumeratorizeWithSize(context, this, "transform_values!", enumSizeFn()); }
@JRubyMethod(name = "transform_values!") public IRubyObject transform_values_bang(final ThreadContext context, final Block block) { if (block.isGiven()) { testFrozen("Hash"); TransformValuesVisitor tvf = new TransformValuesVisitor(); iteratorVisitAll(context, tvf, block); return this; } return enumeratorizeWithSize(context, this, "transform_values!", enumSizeFn()); }
/** rb_hash_select * */ @JRubyMethod(name = "select") public IRubyObject select(final ThreadContext context, final Block block) { final Ruby runtime = context.runtime; if (!block.isGiven()) return enumeratorizeWithSize(context, this, "select", enumSizeFn()); final RubyHash result = newHash(runtime); iteratorVisitAll(context, new SelectVisitor(result), block); return result; }
@JRubyMethod(name = "transform_keys") public IRubyObject transform_keys(final ThreadContext context, final Block block) { if (block.isGiven()) { RubyHash result = newHash(context.runtime); visitAll(context, new TransformKeysVisitor(block), result); return result; } return enumeratorizeWithSize(context, this, "transform_keys", enumSizeFn()); }
/** rb_hash_select * */ @JRubyMethod(name = "select") public IRubyObject select(final ThreadContext context, final Block block) { final Ruby runtime = context.runtime; if (!block.isGiven()) return enumeratorizeWithSize(context, this, "select", enumSizeFn()); final RubyHash result = newHash(runtime); iteratorVisitAll(context, new SelectVisitor(result), block); return result; }
@JRubyMethod(name = "transform_keys") public IRubyObject transform_keys(final ThreadContext context, final Block block) { if (block.isGiven()) { RubyHash result = newHash(context.runtime); visitAll(context, new TransformKeysVisitor(block), result); return result; } return enumeratorizeWithSize(context, this, "transform_keys", enumSizeFn()); }