Class: Whoaz::Whois

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain) ⇒ Whoaz::Whois

Initializes a new Whois object.

Parameters:

  • domain (String)

    The domain name required to query.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/whoaz/whois.rb', line 36

def initialize(domain)
  @domain = domain

  if raw_domain_info.include?('is not exists') || raw_domain_info.include?('cannot be registered')
    @free = true
  else
    @free = false
    domain_info = raw_domain_info.split("\n")
    @nameservers  = domain_info[3].sub('Name Servers:', '').strip.split(',')
    @organization = domain_info[16].sub('Organisation:', '').strip
    @name         = domain_info[17].sub('Name:', '').strip
    @address      = domain_info[19..23].join("\n").strip
    @phone        = domain_info[12].sub('Voice phone:', '').strip
    @fax          = domain_info[13].sub('Fax:', '').strip
    @email        = domain_info[11].sub('Email:', '').strip
  end
end

Instance Attribute Details

#addressString (readonly)

Returns The address of the registrant.

Returns:

  • (String)

    The address of the registrant.



13
14
15
# File 'lib/whoaz/whois.rb', line 13

def address
  @address
end

#domainString (readonly)

Returns The queried domain name.

Returns:

  • (String)

    The queried domain name.



4
5
6
# File 'lib/whoaz/whois.rb', line 4

def domain
  @domain
end

#emailString (readonly)

Returns The email of the registrant.

Returns:

  • (String)

    The email of the registrant.



22
23
24
# File 'lib/whoaz/whois.rb', line 22

def email
  @email
end

#faxString (readonly)

Returns The fax of the registrant.

Returns:

  • (String)

    The fax of the registrant.



19
20
21
# File 'lib/whoaz/whois.rb', line 19

def fax
  @fax
end

#freeBoolean (readonly) Also known as: free?

Returns Availability of the domain.

Returns:

  • (Boolean)

    Availability of the domain.



28
29
30
# File 'lib/whoaz/whois.rb', line 28

def free
  @free
end

#nameString (readonly)

Returns The name of the registrant.

Returns:

  • (String)

    The name of the registrant.



7
8
9
# File 'lib/whoaz/whois.rb', line 7

def name
  @name
end

#nameserversArray (readonly)

Returns An array of nameservers.

Returns:

  • (Array)

    An array of nameservers.



25
26
27
# File 'lib/whoaz/whois.rb', line 25

def nameservers
  @nameservers
end

#organizationString (readonly)

Returns The organization of the registrant.

Returns:

  • (String)

    The organization of the registrant.



10
11
12
# File 'lib/whoaz/whois.rb', line 10

def organization
  @organization
end

#phoneString (readonly)

Returns The phone of the registrant.

Returns:

  • (String)

    The phone of the registrant.



16
17
18
# File 'lib/whoaz/whois.rb', line 16

def phone
  @phone
end

Instance Method Details

#raw_domain_infoString

Returns raw domain info as responded by WHOIS server.

Returns:

  • (String)


64
65
66
# File 'lib/whoaz/whois.rb', line 64

def raw_domain_info
  @raw_domain_info ||= query
end

#registered?Boolean

Checks if the domain name is registered or not.

Returns:

  • (Boolean)


57
58
59
# File 'lib/whoaz/whois.rb', line 57

def registered?
  !free?
end