1 32 package org.jruby.internal.runtime.methods; 33 34 import org.jruby.RubyMethod; 35 import org.jruby.runtime.Arity; 36 import org.jruby.runtime.Block; 37 import org.jruby.runtime.ICallable; 38 import org.jruby.runtime.ThreadContext; 39 import org.jruby.runtime.builtin.IRubyObject; 40 import org.jruby.runtime.callback.Callback; 41 42 46 public class IterateCallable extends AbstractCallable { 47 private Callback callback; 48 private RubyMethod method; 49 50 public IterateCallable(Callback callback, RubyMethod method) { 51 this.callback = callback; 52 this.method = method; 53 } 54 55 public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { 56 return callback.execute(args[0], new IRubyObject[] { method, self }, block); 57 } 58 59 public ICallable dup() { 60 return new IterateCallable(callback, method); 61 } 62 63 public Arity getArity() { 64 return Arity.createArity((int) method.arity().getLongValue()); 65 } 66 } 67 | Popular Tags |