In Files

Parent

Files

Class/Module Index [+]

Quicksearch

Whois::Record

Attributes

parts[R]

@return [Array<Whois::Record::Part>] The parts that compose this record.

server[R]

@return [Whois::Server] The server that originated this record.

Public Class Methods

new(server, parts) click to toggle source

Initializes a new instance with given server and parts.

@param [Whois::Server] server @param [Array<Whois::Record::Part>] parts

# File lib/whois/record.rb, line 32
def initialize(server, parts)
  @parts  = parts
  @server = server
end

Public Instance Methods

==(other) click to toggle source

Returns true if the object is the same object, or is a string and has the same content.

@param [Whois::Record] other The record to compare. @return [Boolean]

# File lib/whois/record.rb, line 71
def ==(other)
  if equal?(other)
    true
  elsif other.is_a?(self.class)
    to_s == other.to_s
  else
    false
  end
end
Also aliased as: eql?
admin_contact() click to toggle source

Shortcut for #admin_contacts.first.

@return [Whois::Record::Contact]

If the property is supported and a contact exists.

@return [nil]

If the property is not supported or the contact doesn't exist.

@see Whois::Record#admin_contacts

# File lib/whois/record.rb, line 191
def admin_contact
  if property_any_supported?(:admin_contacts)
    parser.admin_contacts.first
  end
end
changed?(other) click to toggle source

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]

@see Whois::Record::Parser#changed?

# File lib/whois/record.rb, line 245
def changed?(other)
  !unchanged?(other)
end
contacts() click to toggle source

Collects and returns all the contacts.

@return [Array<Whois::Record::Contact>]

@see Whois::Record::Parser#contacts

# File lib/whois/record.rb, line 218
def contacts
  parser.contacts
end
content() click to toggle source

Joins and returns all record parts into a single string and separates each response with a newline character.

@example Record with one part

record = Whois::Record.new([Whois::Record::Part.new(:body => "First record.")])
record.content
# => "First record."

@example Record with multiple parts

record = Whois::Record.new([Whois::Record::Part.new(:body => "First record."), Whois::Record::Part.new(:body => "Second record.")])
record.content
# => "First record.\nSecond record."

@return [String] The content of this record.

# File lib/whois/record.rb, line 124
def content
  @content ||= parts.map(&:body).join("\n")
end
eql?(other) click to toggle source
Alias for: ==
inspect() click to toggle source

Returns a human-readable representation of this record.

@return [String] The result of {inspect} on content.

# File lib/whois/record.rb, line 61
def inspect
  content.inspect
end
match(pattern) click to toggle source

Invokes {match} on record {content} and returns the match as MatchData or nil.

@param [Regexp, String] pattern The regex pattern to match. @return [MatchData] If pattern matches content @return [nil] If pattern doesn't match content

@see String#match

# File lib/whois/record.rb, line 93
def match(pattern)
  content.match(pattern)
end
match?(pattern) click to toggle source

Invokes {match} and returns true if pattern matches {content}, false otherwise.

@param [Regexp, String] pattern The regex pattern to match. @return [Boolean]

@see match

# File lib/whois/record.rb, line 105
def match?(pattern)
  !content.match(pattern).nil?
end
parser() click to toggle source

Lazy-loads and returns the parser proxy for current record.

@return [Whois::Record::Parser]

# File lib/whois/record.rb, line 132
def parser
  @parser ||= Parser.new(self)
end
properties() click to toggle source

Returns a Hash containing all supported properties for this record along with corresponding values.

@return [{ Symbol => Object }]

# File lib/whois/record.rb, line 156
def properties
  hash = {}
  Parser::PROPERTIES.each { |property| hash[property] = send(property) }
  hash
end
property_any_supported?(property) click to toggle source

Checks if the property passed as symbol is supported in any of the parsers.

@param [Symbol] property The name of the property to check. @return [Boolean]

@see Whois::Record::Parser#property_any_supported?

# File lib/whois/record.rb, line 144
def property_any_supported?(property)
  parser.property_any_supported?(property)
end
registrant_contact() click to toggle source

Shortcut for #registrant_contacts.first.

@return [Whois::Record::Contact]

If the property is supported and a contact exists.

@return [nil]

If the property is not supported or the contact doesn't exist.

@see Whois::Record#registrant_contacts

# File lib/whois/record.rb, line 176
def registrant_contact
  if property_any_supported?(:registrant_contacts)
    parser.registrant_contacts.first
  end
end
respond_to?(symbol, include_private = false) click to toggle source

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/record.rb, line 45
def respond_to?(symbol, include_private = false)
  respond_to_parser_method?(symbol) || super
end
response_incomplete?() click to toggle source

Checks whether this is an incomplete response.

@return [Boolean]

@see Whois::Record::Parser#response_incomplete?

# File lib/whois/record.rb, line 271
def response_incomplete?
  parser.response_incomplete?
end
response_throttled?() click to toggle source

Checks whether this is a throttle response.

@return [Boolean]

@see Whois::Record::Parser#response_throttled?

# File lib/whois/record.rb, line 281
def response_throttled?
  parser.response_throttled?
end
response_unavailable?() click to toggle source

Checks whether this is an unavailable response.

@return [Boolean]

@see Whois::Record::Parser#response_unavailable?

# File lib/whois/record.rb, line 291
def response_unavailable?
  parser.response_unavailable?
end
technical_contact() click to toggle source

Shortcut for #technical_contacts.first.

@return [Whois::Record::Contact]

If the property is supported and a contact exists.

@return [nil]

If the property is not supported or the contact doesn't exist.

@see Whois::Record#technical_contacts

# File lib/whois/record.rb, line 206
def technical_contact
  if property_any_supported?(:technical_contacts)
    parser.technical_contacts.first
  end
end
to_s() click to toggle source

Returns a String representation of this record.

@return [String] The record content.

# File lib/whois/record.rb, line 53
def to_s
  content.to_s
end
unchanged?(other) click to toggle source

The opposite of {changed?}.

@param [Whois::Record] other The other record instance to compare. @return [Boolean]

@see Whois::Record::Parser#unchanged?

# File lib/whois/record.rb, line 256
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.