Parsing a URI's base authority

Hi all,
I am looking for a ruby library to reliably determine the base
authority of a URI host.

example:

www.google.com => google.com
subdomain.domain.com.au => domain.com.au
www1.o2.co.uk => 02.co.uk
blah.jp => blah.jp

here is a javascript based solution to this problem.
http://getoutfoxed.com/node/41

Before trying to port this code in ruby, I was wandering if is there
any already existing ruby gem or
library designed to do this job…
so far I have not been to solve this problem by simply using the uri
parsing facilities included
in the ruby standard library.

thank you in advance,
Andrea