class DomainCheck::SingleCheck

Public Class Methods

new(domain) click to toggle source
# File lib/domain_check/single_check.rb, line 6
def initialize(domain)
  @domain = domain.downcase
end

Public Instance Methods

check() { |result| ... } click to toggle source
# File lib/domain_check/single_check.rb, line 10
def check
  whois = Whois.whois(@domain)
  if whois.available?
    { :domain => @domain, :status => :available }
  else
    result = { :domain => @domain, :status => :registered }

    contact = whois.registrant_contact || whois.admin_contact ||
      whois.technical_contact || whois.contacts.first
    result[:contact_name] = contact.name if contact
    result[:contact_email] = contact.email if contact

    result[:created_at] = whois.created_on
    result[:expires_at] = whois.expires_on

    yield(result) if block_given?
    result
  end
rescue Whois::Error
  { :domain => @domain, :status => :unknown }
end