When you materialize a block with &, it becomes a Proc object, which has an arity method. Just be careful - it returns the one's complement if the proc takes a *splat arg.
def foobar(x, y, z, &block)
p block.arity
end
(Answer via "The Ruby Programming Language" book.)