Use uid or euid in the Process class:
uid
euid
Process
raise 'Must run as root' unless Process.uid == 0
I don't know Ruby, but what you want to check for is if the user ID is 0. In C, you would do this by checking getuid(). From the Unix command line, you could also check the output of id -u.
getuid()
id -u