Class: Whoaz::Whois
- Inherits:
-
Object
- Object
- Whoaz::Whois
- Defined in:
- lib/whoaz/whois.rb
Instance Attribute Summary collapse
-
#address ⇒ String
readonly
The address of the registrant.
-
#domain ⇒ String
readonly
The queried domain name.
-
#email ⇒ String
readonly
The email of the registrant.
-
#fax ⇒ String
readonly
The fax of the registrant.
-
#free ⇒ Boolean
(also: #free?)
readonly
Availability of the domain.
-
#name ⇒ String
readonly
The name of the registrant.
-
#nameservers ⇒ Array
readonly
An array of nameservers.
-
#organization ⇒ String
readonly
The organization of the registrant.
-
#phone ⇒ String
readonly
The phone of the registrant.
Instance Method Summary collapse
-
#initialize(domain) ⇒ Whoaz::Whois
constructor
Initializes a new Whois object.
-
#raw_domain_info ⇒ String
Returns raw domain info as responded by WHOIS server.
-
#registered? ⇒ Boolean
Checks if the domain name is registered or not.
Constructor Details
#initialize(domain) ⇒ Whoaz::Whois
Initializes a new Whois object.
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
#address ⇒ String (readonly)
Returns The address of the registrant.
13 14 15 |
# File 'lib/whoaz/whois.rb', line 13 def address @address end |
#domain ⇒ String (readonly)
Returns The queried domain name.
4 5 6 |
# File 'lib/whoaz/whois.rb', line 4 def domain @domain end |
#email ⇒ String (readonly)
Returns The email of the registrant.
22 23 24 |
# File 'lib/whoaz/whois.rb', line 22 def email @email end |
#fax ⇒ String (readonly)
Returns The fax of the registrant.
19 20 21 |
# File 'lib/whoaz/whois.rb', line 19 def fax @fax end |
#free ⇒ Boolean (readonly) Also known as: free?
Returns Availability of the domain.
28 29 30 |
# File 'lib/whoaz/whois.rb', line 28 def free @free end |
#name ⇒ String (readonly)
Returns The name of the registrant.
7 8 9 |
# File 'lib/whoaz/whois.rb', line 7 def name @name end |
#nameservers ⇒ Array (readonly)
Returns An array of nameservers.
25 26 27 |
# File 'lib/whoaz/whois.rb', line 25 def nameservers @nameservers end |
#organization ⇒ String (readonly)
Returns The organization of the registrant.
10 11 12 |
# File 'lib/whoaz/whois.rb', line 10 def organization @organization end |
#phone ⇒ String (readonly)
Returns The phone of the registrant.
16 17 18 |
# File 'lib/whoaz/whois.rb', line 16 def phone @phone end |
Instance Method Details
#raw_domain_info ⇒ String
Returns raw domain info as responded by WHOIS server.
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.
57 58 59 |
# File 'lib/whoaz/whois.rb', line 57 def registered? !free? end |