}
@JRubyMethod(name = {"to_enum", "enum_for"}, optional = 1, rest = true)
public static IRubyObject obj_to_enum(final ThreadContext context, IRubyObject self, IRubyObject[] args, final Block block) {
String method = "each";
SizeFn sizeFn = null;
if (args.length > 0) {
method = args[0].asJavaString();
args = Arrays.copyOfRange(args, 1, args.length);
}
if (block.isGiven()) {
sizeFn = new SizeFn() {
@Override
public IRubyObject size(IRubyObject[] args) {
return block.call(context, args);
}
};