Quoting Tim Perrett <freestyle_kayaker / hotmail.com>:
>  def displaySheet(sender)
>  NSLog('opening sheet')
> 
>  NSBundle.loadNibNamed_owner('Prefs', self)
>  NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo
> (@prefsWindow, 
> @mainWindow, nil, 'didEndSheet:returnCode:contextInfo', nil)
> 
>  # creates modal session, sheet is displayed at this point
>  NSApp.runModalForWindow(@prefsWindow)
> 
>  NSApp.endSheet(@prefsWindow)
>  #@prefsWindow.orderOut(self)
>  end
> 
>  def didEndSheet_returnCode_contextInfo(sheet, returnCode, context)
>  NSLog('callback')
>  @prefsWindow.orderOut(self)
>  end

You're doing things slightly differently to how i usually do this so I may be slightly off base...

In your begin sheet method your modal delegate is nil so your didEndSelector is going to be sent to nil. 
It should probably be 'self'. The format of your didEndSelector is different from how I would expect. 
That doesn't mean it's wrong but when I do this I make it a symbol the same as the actual method ie...

:didEndSheet_returnCode_contextInfo

I don't think you need the runModalForWindow call. That is what your beginSheet_modalForWindow 
method is doing anyway.

Then you are ending the sheet straight away which probably isn't what you want either. Calling 
endSheet triggers a call to your didEndSelector. You probably want to do that in response to a user 
action eg. 'OK' button.

Here is some code for a login sheet from one of my apps. It may or may not be useful...

    def login_sheet
        OSX::NSApp().beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo
(@login_sheet, @main_window, self, :login_button_returnCode_contextInfo, nil)
    end

    def login_button_returnCode_contextInfo sheet, returnCode, contextInfo
        sheet.orderOut nil
        finish_upload
    end

    def end_login_sheet sender
        @login = @login_field.stringValue
        @password = @password_field.stringValue
        
        OSX::NSApp().endSheet_returnCode @login_sheet, 0
    end
    
    def cancel_login_sheet sender
        OSX::NSApp().endSheet_returnCode @login_sheet, 0
    end
    

PS These sorts of questions might be better directed at the RubyCocoa mailing list...

https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk