Class: DomainCheck::SingleCheck
- Inherits:
-
Object
- Object
- DomainCheck::SingleCheck
- Defined in:
- lib/domain_check/single_check.rb
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(domain) ⇒ SingleCheck
constructor
A new instance of SingleCheck.
Constructor Details
#initialize(domain) ⇒ SingleCheck
Returns a new instance of SingleCheck.
6 7 8 |
# File 'lib/domain_check/single_check.rb', line 6 def initialize(domain) @domain = domain.downcase end |
Instance Method Details
#check ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |