Class: Chkex::DomainInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/chkex/domain_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ DomainInfo

Returns a new instance of DomainInfo.



5
6
7
8
9
10
11
# File 'lib/chkex/domain_info.rb', line 5

def initialize(url)
  @url = url
  @error = nil
  @expires_on = nil

  query
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/chkex/domain_info.rb', line 3

def error
  @error
end

#expires_onObject

Returns the value of attribute expires_on.



3
4
5
# File 'lib/chkex/domain_info.rb', line 3

def expires_on
  @expires_on
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/chkex/domain_info.rb', line 3

def url
  @url
end

Instance Method Details

#queryObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chkex/domain_info.rb', line 13

def query
  begin
    record = Whois.whois(@url)
    @expires_on = record.parser.expires_on

    raise Chkex::DomainNotFound unless @expires_on
  rescue Whois::ServerNotFound
    @error = :no_whois_server
  rescue Whois::AttributeNotImplemented
    @error = :no_expiry
  rescue Whois::ConnectionError
    @error = :connection_error
  rescue Timeout::Error
    @error = :timeout
  rescue Chkex::DomainNotFound => e
    @error = e.message
  rescue NoMethodError
    @error = :no_method
  end
end