parts | [R] | |
parts | [R] | |
server | [R] | |
server | [R] |
# File lib/whois/answer.rb, line 28 def initialize(server, parts) @parts = parts @server = server end
# File lib/whois/answer.rb, line 28 def initialize(server, parts) @parts = parts @server = server end
Returns true if the object is the same object, or is a string and has the same content.
# File lib/whois/answer.rb, line 56 def ==(other) (other.equal?(self)) || # This option should be deprecated (other.is_a?(String) && other == self.to_s) || (other.is_a?(Answer) && other.to_s == self.to_s) end
Returns true if the object is the same object, or is a string and has the same content.
# File lib/whois/answer.rb, line 56 def ==(other) (other.equal?(self)) || # This option should be deprecated (other.is_a?(String) && other == self.to_s) || (other.is_a?(Answer) && other.to_s == self.to_s) end
Returns whether this answer changed compared to other.
Comparing the Answer contents is not always as trivial as it seems. Whois servers sometimes inject dynamic method into the whois answer such as the timestamp the request was generated. This causes two answers to be different even if they actually should be considered equal because the registry data didn‘t change.
This method should provide a bulletproof way to detect whether this answer changed if compared with other.
# File lib/whois/answer.rb, line 96 def changed?(other) !unchanged?(other) end
Returns whether this answer changed compared to other.
Comparing the Answer contents is not always as trivial as it seems. Whois servers sometimes inject dynamic method into the whois answer such as the timestamp the request was generated. This causes two answers to be different even if they actually should be considered equal because the registry data didn‘t change.
This method should provide a bulletproof way to detect whether this answer changed if compared with other.
# File lib/whois/answer.rb, line 96 def changed?(other) !unchanged?(other) end
Returns the content of this answer as a string. This method joins all answer parts into a single string and separates each response with a newline character.
answer = Whois::Answer.new([Whois::Answer::Part.new("First answer.")]) answer.content # => "First answer." answer = Whois::Answer.new([Whois::Answer::Part.new("First answer."), Whois::Answer::Part.new("Second answer.")]) answer.content # => "First answer.\nSecond answer."
# File lib/whois/answer.rb, line 81 def content @content ||= parts.map(&:response).join("\n") end
Returns the content of this answer as a string. This method joins all answer parts into a single string and separates each response with a newline character.
answer = Whois::Answer.new([Whois::Answer::Part.new("First answer.")]) answer.content # => "First answer." answer = Whois::Answer.new([Whois::Answer::Part.new("First answer."), Whois::Answer::Part.new("Second answer.")]) answer.content # => "First answer.\nSecond answer."
# File lib/whois/answer.rb, line 81 def content @content ||= parts.map(&:response).join("\n") end
Lazy-loads and returns a Whois::Answer::Parser proxy for current answer.
# File lib/whois/answer.rb, line 112 def parser @parser ||= Parser.new(self) end
Lazy-loads and returns a Whois::Answer::Parser proxy for current answer.
# File lib/whois/answer.rb, line 112 def parser @parser ||= Parser.new(self) end
Returns a Hash containing all supported properties for this Answer along with corresponding values.
# File lib/whois/answer.rb, line 119 def properties hash = {} Parser::PROPERTIES.each { |property| hash[property] = send(property) } hash end
Returns a Hash containing all supported properties for this Answer along with corresponding values.
# File lib/whois/answer.rb, line 119 def properties hash = {} Parser::PROPERTIES.each { |property| hash[property] = send(property) } hash end
Delegates all method calls to the internal parser.
# File lib/whois/answer.rb, line 136 def method_missing(method, *args, &block) if Parser::PROPERTIES.include?(method) self.class.class_eval "def \#{method}(*args, &block)\nif property_supported?(:\#{method})\nparser.\#{method}(*args, &block)\nelse\nnil\nend\nend\n", __FILE__, __LINE__ + 1 send(method, *args, &block) elsif Parser::METHODS.include?(method) self.class.class_eval "def \#{method}(*args, &block)\nif parser.respond_to?(:\#{method})\nparser.\#{method}(*args, &block)\nend\nend\n", __FILE__, __LINE__ + 1 send(method, *args, &block) elsif method.to_s =~ /([a-z_]+)\?/ and (Parser::PROPERTIES + Parser::METHODS).include?($1.to_sym) self.class.class_eval "def \#{$1}?\n!\#{$1}.nil?\nend\n", __FILE__, __LINE__ + 1 send($1) else super end end
Delegates all method calls to the internal parser.
# File lib/whois/answer.rb, line 136 def method_missing(method, *args, &block) if Parser::PROPERTIES.include?(method) self.class.class_eval "def \#{method}(*args, &block)\nif property_supported?(:\#{method})\nparser.\#{method}(*args, &block)\nelse\nnil\nend\nend\n", __FILE__, __LINE__ + 1 send(method, *args, &block) elsif Parser::METHODS.include?(method) self.class.class_eval "def \#{method}(*args, &block)\nif parser.respond_to?(:\#{method})\nparser.\#{method}(*args, &block)\nend\nend\n", __FILE__, __LINE__ + 1 send(method, *args, &block) elsif method.to_s =~ /([a-z_]+)\?/ and (Parser::PROPERTIES + Parser::METHODS).include?($1.to_sym) self.class.class_eval "def \#{$1}?\n!\#{$1}.nil?\nend\n", __FILE__, __LINE__ + 1 send($1) else super end end