Module: Whois::ParserExtensions::WhoisRecord
- Defined in:
- lib/whois/parser_extensions/whois_record.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#admin_contact ⇒ Whois::Record::Contact?
Shortcut for
#admin_contacts.first. -
#changed?(other) ⇒ Boolean
Checks whether this Record is different than
other. -
#contacts ⇒ Array<Whois::Record::Contact>
Collects and returns all the contacts.
-
#parser ⇒ Whois::Record::Parser
Lazy-loads and returns the parser proxy for current record.
-
#properties ⇒ { Symbol => Object }
Returns a Hash containing all supported properties for this record along with corresponding values.
- #property_any_supported?(property) ⇒ Boolean deprecated Deprecated.
-
#registrant_contact ⇒ Whois::Record::Contact?
Shortcut for
#registrant_contacts.first. -
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Checks if this class respond to given method.
- #response_incomplete? ⇒ Boolean deprecated Deprecated.
- #response_throttled? ⇒ Boolean deprecated Deprecated.
- #response_unavailable? ⇒ Boolean deprecated Deprecated.
-
#technical_contact ⇒ Whois::Record::Contact?
Shortcut for
#technical_contacts.first. -
#unchanged?(other) ⇒ Boolean
The opposite of #changed?.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
Delegates all method calls to the internal parser.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 185 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?(::Regexp.last_match(1).to_sym) self.class.define_question_method(::Regexp.last_match(1)) send(method) else super end end |
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 8 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#admin_contact ⇒ Whois::Record::Contact?
Shortcut for #admin_contacts.first.
64 65 66 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 64 def admin_contact parser.admin_contacts.first end |
#changed?(other) ⇒ Boolean
Checks whether this Record is different than other.
Comparing the 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.
109 110 111 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 109 def changed?(other) !unchanged?(other) end |
#contacts ⇒ Array<Whois::Record::Contact>
Collects and returns all the contacts.
86 87 88 89 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 86 def contacts warn("#{self.class}#contacts is deprecated") parser.contacts end |
#parser ⇒ Whois::Record::Parser
Lazy-loads and returns the parser proxy for current record.
26 27 28 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 26 def parser @parser ||= Parser.new(self) end |
#properties ⇒ { Symbol => Object }
Returns a Hash containing all supported properties for this record along with corresponding values.
35 36 37 38 39 40 |
# 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 |
#property_any_supported?(property) ⇒ Boolean
162 163 164 |
# 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 |
#registrant_contact ⇒ Whois::Record::Contact?
Shortcut for #registrant_contacts.first.
51 52 53 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 51 def registrant_contact parser.registrant_contacts.first end |
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Checks if this class respond to given method.
Overrides the default implementation to add support for Whois::Parser::PROPERTIES and Whois::Parser::METHODS.
18 19 20 |
# 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 |
#response_incomplete? ⇒ Boolean
Checks whether this is an incomplete response.
133 134 135 136 |
# 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 |
#response_throttled? ⇒ Boolean
Checks whether this is a throttle response.
144 145 146 147 |
# 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 |
#response_unavailable? ⇒ Boolean
Checks whether this is an unavailable response.
155 156 157 158 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 155 def response_unavailable? warn("#{self.class}#response_unavailable? is deprecated. Use parser.response_unavailable?") parser.response_unavailable? end |
#technical_contact ⇒ Whois::Record::Contact?
Shortcut for #technical_contacts.first.
77 78 79 |
# File 'lib/whois/parser_extensions/whois_record.rb', line 77 def technical_contact parser.technical_contacts.first end |
#unchanged?(other) ⇒ Boolean
The opposite of #changed?.
119 120 121 122 123 124 125 |
# 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 |