Class: Whois::Client
- Inherits:
-
Object
- Object
- Whois::Client
- Defined in:
- lib/whois/client.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
The maximum time to run a WHOIS query, expressed in seconds.
10
Instance Attribute Summary collapse
-
#settings ⇒ Hash
The current client settings.
-
#timeout ⇒ Fixnum?
The current timeout value, expressed in seconds.
Instance Method Summary collapse
-
#initialize(settings = {}) {|self| ... } ⇒ Client
constructor
Initializes a new
Whois::Client
withsettings
. -
#lookup(object) ⇒ Whois::Record
Lookups the right WHOIS server for
object
and returns the response from the server.
Constructor Details
#initialize(settings = {}) {|self| ... } ⇒ Client
Initializes a new Whois::Client
with settings
.
If block
is given, yields self
.
68 69 70 71 72 73 74 75 |
# File 'lib/whois/client.rb', line 68 def initialize(settings = {}) settings = settings.dup self.timeout = settings.key?(:timeout) ? settings.delete(:timeout) : DEFAULT_TIMEOUT self.settings = settings yield(self) if block_given? end |
Instance Attribute Details
#settings ⇒ Hash
Returns The current client settings.
28 29 30 |
# File 'lib/whois/client.rb', line 28 def settings @settings end |
#timeout ⇒ Fixnum?
Returns The current timeout value, expressed in seconds.
25 26 27 |
# File 'lib/whois/client.rb', line 25 def timeout @timeout end |
Instance Method Details
#lookup(object) ⇒ Whois::Record
Lookups the right WHOIS server for object
and returns the response from the server.
91 92 93 94 95 96 97 98 |
# File 'lib/whois/client.rb', line 91 def lookup(object) string = object.to_s.downcase Timeout.timeout(timeout) do @server = Server.guess(string) @server.configure(settings) @server.lookup(string) end end |