Class Whois::Record::Parser::Base
In: lib/whois/record/parser/base.rb
Parent: Object

Represents the abstract base parser class for all server-specific parser implementations.

NOTE. This class is for the most part auto-generated via meta programming. This is the reason why RDoc can‘t detect and document all available methods.

@abstract

Methods

Attributes

part  [R]  @return [Whois::Record::Part] The part referenced by this parser.

Public Class methods

Initializes a new parser with given part.

@param [Whois::Record::Part] part

Registers a property as :not_implemented and defines the corresponding private _property_PROPERTY method.

A :not_implemented property always raises a PropertyNotImplemented error when the property method is called.

@param [Symbol] property @return [void]

@example Defining a not implemented property

  # Defines a not implemented property called :disclaimer.
  property_not_implemented(:disclaimer)

Registers a property as :not_supported and defines the corresponding private _property_PROPERTY method.

A :not_implemented property always raises a PropertyNotSupported error when the property method is called.

@param [Symbol] property @return [void]

@example Defining an unsupported property

  # Defines an unsupported property called :disclaimer.
  property_not_supported(:disclaimer)

Registers a property in the registry.

@param [Symbol] property @param [Symbol] status

@return [void]

Check if the property passed as symbol is registered in the registry for current parser.

@param [Symbol] property @param [Symbol] status @return [Boolean]

@example Not-registered property

  property_registered?(:disclaimer)
  # => false

@example Registered property

  property_register(:disclaimer) {}
  property_registered?(:disclaimer)
  # => true

Returns the status for the property passed as symbol.

@param [Symbol] property @return [Symbol, nil]

@example Undefined property

  property_status(:disclaimer)
  # => nil

@example Defined property

  property_register(:disclaimer, :supported) {}
  property_status(:disclaimer)
  # => :supported

Registers a property as :supported and defines the corresponding private _property_PROPERTY method.

@param [Symbol] property @return [void]

@example Defining a supported property

  # Defines a supported property called :disclaimer.
  property_supported(:disclaimer) do
    ...
  end

Public Instance methods

Checks whether the content of this part is different than other.

Comparing a WHOIS response 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 [Base] other The other parser instance to compare. @return [Boolean]

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

Collects and returns all the available contacts.

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

@see Whois::Record#contacts @see Whois::Record::Parser#contacts

This is an internal method primary used as a common access point to get the content to be parsed as a string.

The main reason behind this method is because, in the past, the internal representation of the data to be parsed changed several times, and I always had to rewrite all single parsers in order to reflect these changes. Now, as far as the parser access the data via the content method, there‘s no need to change each single implementation in case the content source changes.

That said, the only constraints about this method is to return the data to be parsed as string.

@return [String] The part body.

Check if the parser respond to symbol and calls the method if defined. The method referenced by the symbol is supposed to be a question? method and to return a boolean.

@param [Symbol] symbol @return [Boolean]

@example

  is(:response_throttled?)
  # => true

@api private

Checks if the property passed as symbol is supported by the current parser.

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

Checks whether this is an incomplete response.

@return [Boolean]

@abstract This method is just a stub.

          Define it in your parser class.

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

Checks whether this is a throttle response.

@return [Boolean]

@abstract This method is just a stub.

          Define it in your parser class.

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

Checks whether this response contains a message that can be reconducted to a "WHOIS Server Unavailable" status.

Some WHOIS servers returns error messages when they are experiencing failures.

@return [Boolean]

@abstract This method is just a stub.

          Define it in your parser class.

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

The opposite of {changed?}.

@param [Base] other The other parser instance to compare. @return [Boolean]

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

@api private

Protected Instance methods

[Validate]