public static IRubyObject each_object( ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { RubyModule rubyClass; if (args.length == 0) { rubyClass = recv.getRuntime().getObject(); } else { if (!(args[0] instanceof RubyModule)) throw recv.getRuntime().newTypeError("class or module required"); rubyClass = (RubyModule) args[0]; } Ruby runtime = recv.getRuntime(); int count = 0; if (rubyClass != runtime.getClassClass()) { if (!runtime.isObjectSpaceEnabled()) { throw runtime.newRuntimeError( "ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable"); } Iterator iter = recv.getRuntime().getObjectSpace().iterator(rubyClass); IRubyObject obj = null; while ((obj = (IRubyObject) iter.next()) != null) { count++; block.yield(context, obj); } } else { Iterator iter = runtime.getObject().subclasses(true).iterator(); while (iter.hasNext()) { IRubyObject obj = (IRubyObject) iter.next(); if (obj instanceof RubyClass && ((RubyClass) obj).isIncluded()) { continue; } count++; block.yield(context, obj); } } return recv.getRuntime().newFixnum(count); }
public IRubyObject setValue(IRubyObject newValue) { throw runtime.newRuntimeError("cannot assign to $$"); }
@Deprecated public static RubyProc newProc(Ruby runtime, Block.Type type) { throw runtime.newRuntimeError("deprecated RubyProc.newProc with no block; do not use"); }