@RubyLevelMethod(name = "sleep", module = true) public static RubyValue sleep(RubyValue receiver, RubyValue arg) { long milliseconds = RubyTypesUtil.convertToJavaLong(arg) * 1000; long startTime = System.currentTimeMillis(); RubyThread.sleep(milliseconds); long endTime = System.currentTimeMillis(); return ObjectFactory.createFixnum((int) Math.round((endTime - startTime) / 1000.0)); }
@RubyLevelMethod(name = "exit", module = true) public static RubyValue exit(RubyValue receiver, RubyValue arg) { // TODO should raise SystemExit exception and call at_exit blocks int status; if (arg == RubyConstant.QTRUE) { status = 0; } else if (arg == RubyConstant.QFALSE) { status = 1; } else { status = arg.toInt(); } System.exit(status); return RubyConstant.QNIL; }
@RubyLevelMethod(name = "exit", module = true) public static RubyValue exit(RubyValue receiver) { // TODO should raise SystemExit exception and call at_exit blocks System.exit(0); return RubyConstant.QNIL; }