Self-updating gem

assuming that a gem runs with sufficient permissions is it possible
to update the gem itself from the code?

In my program, I would like to offer a user option “check for updates”
and when a newer version of the gem is available, do a guided gem
install in the background and then restart the application.

Is that possible and, if yes, where would be a good place to start
reading?

Thanks,
T