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::Clientwithsettings. -
#lookup(object) ⇒ Whois::Record
Lookups the right WHOIS server for
objectand 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.
66 67 68 69 70 71 72 73 |
# File 'lib/whois/client.rb', line 66 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.
26 27 28 |
# File 'lib/whois/client.rb', line 26 def settings @settings end |
#timeout ⇒ Fixnum?
Returns The current timeout value, expressed in seconds.
23 24 25 |
# File 'lib/whois/client.rb', line 23 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.
89 90 91 92 93 94 95 96 |
# File 'lib/whois/client.rb', line 89 def lookup(object) string = object.to_s.downcase Timeout.timeout(timeout) do @server = Server.guess(string) @server.configure(settings) @server.lookup(string) end end |