The gem public_suffix is a domain name parser, written in Ruby, and based on the Public Suffix List.

The library is trusted by several large companies and applications, including:

PublicSuffix.domain("google.com")
# => "google.com"
PublicSuffix.domain("www.google.com")
# => "google.com"
PublicSuffix.domain("www.google.co.uk")
# => "google.co.uk"

Gem sourceOther Public Suffix libraries