Sha256: 47398293a596e841e258d38781708df18d142e7bc582432ac719de5315bb576d

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

#
# = Ruby Whois
#
# An intelligent pure Ruby WHOIS client.
#
#
# Category::    Net
# Package::     Whois
# Author::      Simone Carletti <weppos@weppos.net>
# License::     MIT License
#
#--
#
#++


require 'socket'
require 'timeout'


module Whois

  class Client

    # The maximum time to run a whois query expressed in seconds
    DEFAULT_TIMEOUT = 5

    attr_accessor :timeout


    #
    # :call-seq:
    #   new { |client| ... } => client
    #   new(options = {}) { |client| ... } => client
    # 
    # Initializes a new Whois::Client with <tt>options</tt>.
    # 
    # If block is given, yields self.
    # 
    #   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
    
    
    def query(qstring)
      Timeout::timeout(timeout) do
        @server = Server.guess(qstring)
        @server.query(qstring)
      end
    end
      
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whois-0.5.3 lib/whois/client.rb
whois-0.5.2 lib/whois/client.rb