In Files

Parent

Namespace

Files

Class/Module Index [+]

Quicksearch

Whois::Record::Parser

The parsing controller that stays behind the {Whois::Record}.

It provides object-oriented access to a WHOIS response. The list of properties and methods is available in the following constants:

Constants

METHODS
PROPERTIES
SaudinicNetSa

Parser for the saudinic.net.sa server. Aliases the whois.nic.net.sa parser.

WhoisAusregistryNetAu

Parser for the whois.ausregistry.net.au server. Aliases the whois.audns.net.au.

WhoisCnnicNetCn

Parser for the whois.cnnic.net.cn server. Aliases the whois.cnnic.cn parser.

WhoisFicoraFi

Parser for the whois.ficora.fi server.

It aliases the whois.fi parser.

WhoisHkdnrNetHk

Parser for the whois.hkdnr.net.hk server. Aliases the whois.hkirc.hk parser.

WhoisNetUa

Parser for the whois.net.ua server.

It aliases the whois.ua parser.

WhoisNicLa

Parser for the whois.nic.la server.

It aliases the whois.centralnic.com parser because the .LA TLD is powered by Centralnic.

WhoisNicOrKr

Parser for the whois.nic.or.kr server.

It aliases the whois.kr parser.

WhoisPublicinterestregistryNet

Parser for the whois.publicinterestregistry.net server. Aliases the whois.pir.org parser.

WhoisRipnNet

Parser for the whois.ripn.net server. Aliases the whois.tcinet.ru parser.

Attributes

record[R]

@return [Whois::Record] The record referenced by this parser.

Public Class Methods

autoload(name) click to toggle source

Requires the file at whois/record/parser/#{name}.

@param [String] name The file name to load.

@return [void]

# File lib/whois/record/parser.rb, line 128
def self.autoload(name)
  require "whois/record/parser/#{name}"
end
host_to_parser(host) click to toggle source

Converts host to the corresponding parser class name.

@param [String] host The server host. @return [String] The class name.

@example

Parser.host_to_parser("whois.nic.it")
# => "WhoisNicIt"

Parser.host_to_parser("whois.nic-info.it")
# => "WhoisNicInfoIt"
# File lib/whois/record/parser.rb, line 116
def self.host_to_parser(host)
  host.to_s.downcase.
    gsub(/[.-]/, '_').
    gsub(/(?:^|_)(.)/)  { $1.upcase }
end
new(record) click to toggle source

Initializes and return a new parser from record.

@param [Whois::Record] record

# File lib/whois/record/parser.rb, line 141
def initialize(record)
  @record = record
end
parser_for(part) click to toggle source

Returns the proper parser instance for given part. The parser class is selected according to the value of the #host attribute for given part.

@param [Whois::Record::Part] part The part to get the parser for.

@return [Whois::Record::Parser::Base]

An instance of the specific parser for given part.
The instance is expected to be a child of {Whois::Record::Parser::Base}.

@example

# Parser for a known host
Parser.parser_for("whois.example.com")
# => #<Whois::Record::Parser::WhoisExampleCom>

# Parser for an unknown host
Parser.parser_for("missing.example.com")
# => #<Whois::Record::Parser::Blank>
# File lib/whois/record/parser.rb, line 62
def self.parser_for(part)
  parser_klass(part.host).new(part)
end
parser_klass(host) click to toggle source

Detects the proper parser class according to given host and returns the class constant.

This method autoloads missing parser classes. If you want to define a custom parser, simple make sure the class is loaded in the Ruby environment before this method is called.

@param [String] host The server host.

@return [Class] The instance of Class representing the parser Class

corresponding to <tt>host</tt>. If <tt>host</tt> doesn't have
a specific parser implementation, then returns
the {Whois::Record::Parser::Blank} {Class}.
The {Class} is expected to be a child of {Whois::Record::Parser::Base}.

@example

Parser.parser_klass("missing.example.com")
# => Whois::Record::Parser::Blank

# Define a custom parser for missing.example.com
class Whois::Record::Parser::MissingExampleCom
end

Parser.parser_klass("missing.example.com")
# => Whois::Record::Parser::MissingExampleCom
# File lib/whois/record/parser.rb, line 93
def self.parser_klass(host)
  name = host_to_parser(host)
  Parser.const_defined?(name) || autoload(host)
  Parser.const_get(name)

rescue LoadError
  Parser.const_defined?("Blank") || autoload("blank")
  Parser::Blank
end

Public Instance Methods

changed?(other) click to toggle source

Loop through all the record parts to check if at least one part changed.

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

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

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

Collects and returns all the contacts from all the record parts.

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

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

# File lib/whois/record/parser.rb, line 187
def contacts
  parsers.map(&:contacts).flatten
end
parsers() click to toggle source

Returns an array with all host-specific parsers initialized for the parts contained into this parser. The array is lazy-initialized.

@return [Array<Whois::Record::Parser::Base>]

# File lib/whois/record/parser.rb, line 162
def parsers
  @parsers ||= init_parsers
end
property_supported?(property) click to toggle source

Returns true if the property passed as symbol is supported by any available parser.

@return [Boolean]

@see Whois::Record::Parser::Base.property_supported?

# File lib/whois/record/parser.rb, line 173
def property_supported?(property)
  parsers.any? { |parser| parser.property_supported?(property) }
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 {PROPERTIES} and {METHODS}.

@return [Boolean]

# File lib/whois/record/parser.rb, line 151
def respond_to?(symbol, include_private = false)
  super || PROPERTIES.include?(symbol) || METHODS.include?(symbol)
end
response_incomplete?() click to toggle source

Loop through all the parts to check if at least one part is an incomplete response.

@return [Boolean]

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

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

Loop through all the parts to check if at least one part is a throttle response.

@return [Boolean]

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

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

Loop through all the parts to check if at least one part is an unavailable response.

@return [Boolean]

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

# File lib/whois/record/parser.rb, line 258
def response_unavailable?
  any_is?(parsers, :response_unavailable?)
end
unchanged?(other) click to toggle source

The opposite of {changed?}.

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

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

# File lib/whois/record/parser.rb, line 217
def unchanged?(other)
  unless other.is_a?(self.class)
    raise(ArgumentError, "Can't compare `#{self.class}' with `#{other.class}'")
  end

  equal?(other) ||
  parsers.size == other.parsers.size && all_in_parallel?(parsers, other.parsers) { |one, two| one.unchanged?(two) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.