Ncurses Panel userptr issues

I am having issues with the userptr in Ncurses Panel. The C program I
converted from runs fine on my system.
(http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/panels.html - the one
that takes tabs to travel through 3 panels).

I wrote it in ruby, the 3 panels display fine, but the program
terminates on tabbing with no message.

I feel the issue lies in the userptr - I have no samples to go on. Can
someone check this out. I tried both these variations:

Ncurses::Panel.set_panel_userptr(my_panels[0], my_panels[1]);
Ncurses::Panel.set_panel_userptr(my_panels[1], my_panels[2]);
Ncurses::Panel.set_panel_userptr(my_panels[2], my_panels[0]);
#my_panels[0].set_panel_userptr( my_panels[1]);
#my_panels[1].set_panel_userptr( my_panels[2]);
#my_panels[2].set_panel_userptr( my_panels[0]);

Later on tabbing my code is:

when 9:
top = Ncurses::Panel.panel_userptr(top);
Ncurses::Panel.top_panel(top);
break;

Thanks in advance.