class NZWhois::Client
Client
used to fetch NZ WHOIS data and delegate parser results
Public Class Methods
whois(domain)
click to toggle source
Class helper for whois instance method @param [String] domain Domain name to fetch WHOIS data for @return Client
instance
# File lib/nz-whois/client.rb, line 17 def self.whois(domain) new.whois domain end
Public Instance Methods
inspect()
click to toggle source
# File lib/nz-whois/client.rb, line 33 def inspect format( '#<%<class_name>s:0x%<object_id>p @valid_whois=%<valid_whois>s">', class_name: self.class.name, object_id: object_id, valid_whois: valid_whois? ) end
valid_whois?()
click to toggle source
Returns whether the whois response is valid @return Boolean
# File lib/nz-whois/client.rb, line 46 def valid_whois? @status == '200' && parser.valid_whois? end
whois(domain)
click to toggle source
Fetch WHOIS data for a domain name @param [String] domain Domain name to fetch WHOIS data for @return Client
instance (`self`)
# File lib/nz-whois/client.rb, line 26 def whois(domain) raise InvalidDomainError unless domain.to_s =~ /\.nz\z/i fetch_content domain self end
Private Instance Methods
fetch_content(domain)
click to toggle source
# File lib/nz-whois/client.rb, line 57 def fetch_content(domain) open("https://dnc.org.nz/whois/search?domain_name=#{domain}") do |f| @status = f.status.first @content = f.read end rescue OpenURI::HTTPError => e @status = e.message.strip end
parser()
click to toggle source
# File lib/nz-whois/client.rb, line 66 def parser @parser ||= Parser.new @content end