In short, you can't. At least not without a slew of hoop jumping.
attach_function
does what it says; it binds a C function into the Ruby runtime. beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:
is not a C function; it is a selector.
What you really want to bind is the implementation of that selector.
But not really.
What you'd really want to bind is objc_msgSend
with a type signature that includes all the arguments to that method. And you'll also need to attach sel_getUid
. Oh, and you'll need to attach objc_lookUpClass
Then you would do something like (pseudo code):
... attach objc_msgSend to msgSend with no arguments and object return type ...
alert = msgSend(msgSend(msgSend(lookupClass("NSAlert"),getUid("alloc")),
getUid("init")), getUid("autorelease"))
... attach objc_msgSend to bs with all the arguments for beginSheetModal....
bs(alert, getUid("beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo", ... all the arguments ...))
Or something like that.
At which point, you've re-invented a very rudimentary form of MacRuby or RubyCocoa.