Class: Whois::Server::Adapters::Formatted
- Defined in:
- lib/whois/server/adapters/formatted.rb
Overview
Formatted Adapter
The Formatted adapter is almost equal to the Standard adapter. It accepts a :format
adapter to format the WHOIS query.
a = Standard.new(:tld, ".it", "whois.nic.it", :format => "HELLO %s")
# performs a query for the string "HELLO example.it"
a.request("example.it")
Options
The following options can be supplied to customize the creation of a new instance:
-
:port
- Specifies a port number different than 43 -
:format
- Specifies the format rule to apply to the query string
Constant Summary
Constants inherited from Base
Base::DEFAULT_BIND_HOST, Base::DEFAULT_WHOIS_PORT
Instance Attribute Summary
Attributes inherited from Base
#allocation, #buffer, #host, #options, #type
Instance Method Summary collapse
-
#request(string) ⇒ void
Executes a WHOIS query to the WHOIS interface listening at
host
and appends the response to the client buffer.
Methods inherited from Base
#==, #configure, #initialize, #lookup, #query_handler
Constructor Details
This class inherits a constructor from Whois::Server::Adapters::Base
Instance Method Details
#request(string) ⇒ void
This method returns an undefined value.
Executes a WHOIS query to the WHOIS interface listening at host
and appends the response to the client buffer.
The standard port of a WHOIS request is 43. You can customize it by passing a :port
option.
50 51 52 53 54 |
# File 'lib/whois/server/adapters/formatted.rb', line 50 def request(string) [:format] || raise(ServerError, "Missing mandatory :format option for adapter `Formatted'") response = query_the_socket(format([:format], string), host) buffer_append response, host end |