class NZWhois::Parser
WHOIS content parser
Public Class Methods
new(content)
click to toggle source
# File lib/nz-whois/parser.rb, line 11 def initialize(content) @content = content end
Public Instance Methods
admin_contact()
click to toggle source
# File lib/nz-whois/parser.rb, line 57 def admin_contact return unless valid_whois? Contact.new self, 'Admin Contact' end
content_for(description)
click to toggle source
# File lib/nz-whois/parser.rb, line 73 def content_for(description) contents_for(description).first end
delegation_requested?()
click to toggle source
# File lib/nz-whois/parser.rb, line 37 def delegation_requested? boolean_for? 'Domain Delegate Requested' end
domain_signed?()
click to toggle source
# File lib/nz-whois/parser.rb, line 41 def domain_signed? boolean_for? 'Domain Signed' end
expires_on()
click to toggle source
# File lib/nz-whois/parser.rb, line 29 def expires_on nz_date_for 'Domain Date Billed Until' end
last_modified_on()
click to toggle source
# File lib/nz-whois/parser.rb, line 33 def last_modified_on nz_date_for 'Domain Date Last Modified' end
name_servers()
click to toggle source
# File lib/nz-whois/parser.rb, line 69 def name_servers contents_for 'NS Name ' end
registered_on()
click to toggle source
# File lib/nz-whois/parser.rb, line 25 def registered_on nz_date_for 'Domain Date Registered' end
registrant_contact()
click to toggle source
# File lib/nz-whois/parser.rb, line 51 def registrant_contact return unless valid_whois? Contact.new self, 'Registrant Contact' end
registrar()
click to toggle source
# File lib/nz-whois/parser.rb, line 45 def registrar return unless valid_whois? Contact.new self, 'Registrar' end
status()
click to toggle source
# File lib/nz-whois/parser.rb, line 21 def status content_for 'Query Status' end
technical_contact()
click to toggle source
# File lib/nz-whois/parser.rb, line 63 def technical_contact return unless valid_whois? Contact.new self, 'Technical Contact' end
valid_whois?()
click to toggle source
# File lib/nz-whois/parser.rb, line 15 def valid_whois? return @valid_whois if defined? @valid_whois @valid_whois = !whois_content.empty? && !request_denied? end
Private Instance Methods
boolean_for?(description)
click to toggle source
# File lib/nz-whois/parser.rb, line 107 def boolean_for?(description) boolean_string = content_for description boolean_string == 'yes' if boolean_string end
contents_for(description)
click to toggle source
# File lib/nz-whois/parser.rb, line 91 def contents_for(description) return [] unless valid_whois? whois_content.xpath("//td/*[text() = '#{description}']").map do |element| element.ancestors('td').first.next_element.text end end
nz_date_for(description)
click to toggle source
# File lib/nz-whois/parser.rb, line 99 def nz_date_for(description) date_string = content_for description return unless date_string # Add 12 hours (ie NZ) -- ignoring DST Time.parse(date_string + ' GMT') + 12 * 3600 end
page()
click to toggle source
# File lib/nz-whois/parser.rb, line 79 def page @page ||= Nokogiri::HTML @content end
request_denied?()
click to toggle source
# File lib/nz-whois/parser.rb, line 87 def request_denied? page.css('.page-title').text.include? '(Request Denied)' end
whois_content()
click to toggle source
# File lib/nz-whois/parser.rb, line 83 def whois_content @whois_content ||= page.xpath("//*[@id='block-dnc-content']") end