module Whois::ParserExtensions::WhoisRecord
Public Class Methods
# File lib/whois/parser_extensions/whois_record.rb, line 8 def self.included(base) base.extend ClassMethods end
Public Instance Methods
Shortcut for #admin_contacts.first
.
@see Whois::Record#admin_contacts
@return [Whois::Record::Contact]
If the property is supported and a contact exists.
@return [nil]
If the contact doesn't exist.
@raise [Whois::AttributeNotSupported, Whois::AttributeNotImplemented]
# File lib/whois/parser_extensions/whois_record.rb, line 64 def admin_contact parser.admin_contacts.first end
Checks whether this {Whois::Record} is different than other
.
Comparing the {Whois::Record} content is not as trivial as you may think. WHOIS servers can inject into the WHOIS response strings that changes at every request, such as the timestamp the request was generated or the number of requests left for your current IP.
These strings causes a simple equal comparison to fail even if the registry data is the same.
This method should provide a bulletproof way to detect whether this record changed compared with other
.
@param [Whois::Record] other The other record instance to compare. @return [Boolean]
# File lib/whois/parser_extensions/whois_record.rb, line 109 def changed?(other) !unchanged?(other) end
Collects and returns all the contacts.
@return [Array<Whois::Record::Contact>]
# File lib/whois/parser_extensions/whois_record.rb, line 86 def contacts warn("#{self.class}#contacts is deprecated") parser.contacts end
Lazy-loads and returns the parser proxy for current record.
@return [Whois::Record::Parser]
# File lib/whois/parser_extensions/whois_record.rb, line 26 def parser @parser ||= Parser.new(self) end
Returns a Hash containing all supported properties for this record along with corresponding values.
@return [{ Symbol => Object
}] @raise [Whois::AttributeNotSupported, Whois::AttributeNotImplemented]
# File lib/whois/parser_extensions/whois_record.rb, line 35 def properties warn("#{self.class}#properties is deprecated") hash = {} Parser::PROPERTIES.each { |property| hash[property] = send(property) } hash end
@deprecated
# File lib/whois/parser_extensions/whois_record.rb, line 162 def property_any_supported?(property) warn("#{self.class}#property_any_supported? is deprecated and has no effect. Use Whois::Parser.property_any_supported? if you need it.") end
Shortcut for #registrant_contacts.first
.
@see Whois::Record#registrant_contacts
@return [Whois::Record::Contact]
If the property is supported and a contact exists.
@return [nil]
If the the contact doesn't exist.
@raise [Whois::AttributeNotSupported, Whois::AttributeNotImplemented]
# File lib/whois/parser_extensions/whois_record.rb, line 51 def registrant_contact parser.registrant_contacts.first end
Checks if this class respond to given method.
Overrides the default implementation to add support for {Parser::PROPERTIES} and {Parser::METHODS}.
@return [Boolean]
# File lib/whois/parser_extensions/whois_record.rb, line 18 def respond_to_missing?(symbol, include_private = false) respond_to_parser_method?(symbol) || super end
Checks whether this is an incomplete response.
@deprecated @see Whois::Parser#response_incomplete?
@return [Boolean]
# File lib/whois/parser_extensions/whois_record.rb, line 133 def response_incomplete? warn("#{self.class}#response_incomplete? is deprecated. Use parser.response_incomplete?") parser.response_incomplete? end
Checks whether this is a throttle response.
@deprecated @see Whois::Parser#response_throttled?
@return [Boolean]
# File lib/whois/parser_extensions/whois_record.rb, line 144 def response_throttled? warn("#{self.class}#response_throttled? is deprecated. Use parser.response_throttled?") parser.response_throttled? end
Shortcut for #technical_contacts.first
.
@see Whois::Record#technical_contacts
@return [Whois::Record::Contact]
If the property is supported and a contact exists.
@return [nil]
If the contact doesn't exist.
@raise [Whois::AttributeNotSupported, Whois::AttributeNotImplemented]
# File lib/whois/parser_extensions/whois_record.rb, line 77 def technical_contact parser.technical_contacts.first end
The opposite of {#changed?}.
@param [Whois::Record] other The other record instance to compare. @return [Boolean]
# File lib/whois/parser_extensions/whois_record.rb, line 119 def unchanged?(other) unless other.is_a?(self.class) raise(ArgumentError, "Can't compare `#{self.class}' with `#{other.class}'") end equal?(other) || parser.unchanged?(other.parser) end
Private Instance Methods
Delegates all method calls to the internal parser.
# File lib/whois/parser_extensions/whois_record.rb, line 184 def method_missing(method, *args, &block) if Parser::PROPERTIES.include?(method) self.class.define_property_method(method) send(method, *args, &block) elsif Parser::METHODS.include?(method) self.class.define_method_method(method) send(method, *args, &block) elsif method.to_s =~ /([a-z_]+)\?/ and (Parser::PROPERTIES + Parser::METHODS).include?($1.to_sym) self.class.define_question_method($1) send(method) else super end end
@api private
# File lib/whois/parser_extensions/whois_record.rb, line 170 def respond_to_parser_method?(symbol) Parser::PROPERTIES.include?(symbol) || Parser::METHODS.include?(symbol) || respond_to_question_method?(symbol) end
# File lib/whois/parser_extensions/whois_record.rb, line 176 def respond_to_question_method?(symbol) return false unless symbol.to_s =~ /([a-z_]+)\?/ symbol = $1.to_sym Parser::PROPERTIES.include?(symbol) || Parser::METHODS.include?(symbol) end