Class: Dnsmadeeasy_verify::Domain
- Inherits:
-
Object
- Object
- Dnsmadeeasy_verify::Domain
- Includes:
- Dnsruby
- Defined in:
- lib/dnsmadeeasy_verify/domain.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #available ⇒ Object
- #do_name_servers_contain(domain) ⇒ Object
- #get_name_servers ⇒ Object
-
#initialize(name) ⇒ Domain
constructor
A new instance of Domain.
- #registered ⇒ Object
Constructor Details
#initialize(name) ⇒ Domain
Returns a new instance of Domain.
10 11 12 |
# File 'lib/dnsmadeeasy_verify/domain.rb', line 10 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/dnsmadeeasy_verify/domain.rb', line 8 def name @name end |
Instance Method Details
#available ⇒ Object
14 15 16 17 |
# File 'lib/dnsmadeeasy_verify/domain.rb', line 14 def available @whois ||= Whois.whois(@name) @whois.available? end |
#do_name_servers_contain(domain) ⇒ Object
24 25 26 27 |
# File 'lib/dnsmadeeasy_verify/domain.rb', line 24 def do_name_servers_contain(domain) name_servers = get_name_servers return name_servers.any?{ |s| s.downcase().include?(domain) } end |
#get_name_servers ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dnsmadeeasy_verify/domain.rb', line 29 def get_name_servers ns = [] res = Dnsruby::Resolver.new res.retry_times=(2) ns_req = nil begin ns_req = res.query(@name, "NS") rescue Exception => e return [] end if (ns_req.header.ancount == 0) return [] end ns_req = res.query(@name, "NS") (ns_req.answer.select {|r| r.type == "NS"}).each do |nsrr| ns << nsrr.domainname.to_s end ns end |
#registered ⇒ Object
19 20 21 22 |
# File 'lib/dnsmadeeasy_verify/domain.rb', line 19 def registered @whois ||= Whois.whois(@name) @whois.registered? end |