Sha256: 16d928a8ab01f74e3f543a26b5c02bd07d8dcc8fe359cae4ddb61ac451b76809
Contents?: true
Size: 1.89 KB
Versions: 4
Compression:
Stored size: 1.89 KB
Contents
# # = Ruby Whois # # An intelligent pure Ruby WHOIS client and parser. # # # Category:: Net # Package:: Whois # Author:: Simone Carletti <weppos@weppos.net> # License:: MIT License # #-- # #++ require 'timeout' module Whois class Client # The Integer maximum time to run a whois query, expressed in seconds. DEFAULT_TIMEOUT = 10 attr_accessor :timeout # # :call-seq: # new { |client| ... } => client # new(options = {}) { |client| ... } => client # # Initializes a new <tt>Whois::Client</tt> with <tt>options</tt>. # # ==== Parameters # # options:: Hash of options (default: {}): # :timeout - The Integer script timeout, expressed in seconds (default: DEFAULT_TIMEOUT). # # If <tt>block</tt> is given, yields <tt>self</tt>. # # ==== Returns # # Whois::Client:: The client instance. # # ==== Examples # # client = Whois::Client.new do |c| # c.timeout = nil # end # client.query("google.com") # def initialize(options = {}, &block) self.timeout = options[:timeout] || DEFAULT_TIMEOUT yield(self) if block_given? end class Query # :nodoc: # IPv6? # RPSL? # email? # NSIC? # ASP32? # IP? # domain? # network? end # Queries the right WHOIS server for <tt>qstring</tt> and returns # the response from the server. # # ==== Parameters # # qstring:: The String to be sent as query parameter. # # ==== Returns # # Whois::Answer:: The answer object containing the WHOIS response. # # ==== Examples # # client.query("google.com") # # => #<Whois::Answer> # def query(qstring) string = qstring.to_s Timeout::timeout(timeout) do @server = Server.guess(string) @server.query(string) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
whois-1.3.4 | lib/whois/client.rb |
whois-1.3.3 | lib/whois/client.rb |
whois-1.3.2 | lib/whois/client.rb |
whois-1.3.1 | lib/whois/client.rb |