Something along the lines of:
def domain_exists?(domain)
# perform check
# return true|false
end
puts "valid!" if domain_exists?("example.com")
If you want to check whether a domain is registered or not, then you need to perform a Whois query. http://www.ruby-whois.org/