Sha256: 423cd31269573c349470f7cd7b6f476bcc92ba7b63ab929558286a26df69baae

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

module Chkex
  class DomainInfo
    attr_accessor :error, :url, :expires_on

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

      query
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chkex-0.1.1 lib/chkex/domain_info.rb
chkex-0.1.0 lib/chkex/domain_info.rb