Class: DomainChecker

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

Overview

DomainChecker handles checking domain availability using Namecheap API. Supports both exact domain check and suggestions with common TLDs.

Constant Summary collapse

COMMON_TLDS =
%w[.com .net .org .io .dev .app .co .xyz .tech .site].freeze

Instance Method Summary collapse

Constructor Details

#initialize(domain) ⇒ DomainChecker

Initialize with the domain string to check.

domain - String domain or base name (e.g. “example” or “example.com”)



14
15
16
17
# File 'lib/domain_checker.rb', line 14

def initialize(domain)
  @domain = domain
  @client = ApiClients::NamecheapClient.new
end

Instance Method Details

#checkObject

Perform the domain availability check.

Returns a Hash with keys:

  • :available (Boolean)

  • :domain (String)

  • :message (String, colorized)

  • :link (String URL if available)

  • :suggestions (Array of [domain, available] for common TLDs if no exact domain)



27
28
29
30
31
32
33
# File 'lib/domain_checker.rb', line 27

def check
  if exact_domain?(@domain)
    check_exact_domain(@domain)
  else
    check_domain_suggestions(@domain)
  end
end