Skip to content

Commit

Permalink
Documented main Whois file.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Sep 20, 2009
1 parent c5e607d commit 58726ad
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions lib/whois.rb
Expand Up @@ -29,14 +29,28 @@ module Whois
AUTHORS = ['Simone Carletti <weppos@weppos.net>']


def self.query(qstring)
Client.new.query(qstring)
end

# Queries the right whois server for <tt>qstring</tt> and returns
# a Whois::Answer instance containing the response from the server.
def self.whois(qstring)
query(qstring)
end

# Returns <tt>true</tt> whether <tt>qstring</tt> is available.
# <tt>qstring</tt> is intended to be a domain name,
# otherwise this method may return unexpected responses.
#
# Whois.available?("google.com")
# # => false
#
# Whois.available?("google-is-not-available-try-again-later.com")
# # => true
#
# Warning: this method is only available if a Whois parser exists
# for <tt>qstring</tt> top level domain. Otherwise you'll get a warning message
# and the method will return <tt>nil</tt>.
# This is a technical limitation. Browse the lib/whois/answer/parsers folder
# to view all available parsers.
#
def self.available?(qstring)
query(qstring).available?
rescue ParserNotFound => e
Expand All @@ -45,12 +59,34 @@ def self.available?(qstring)
nil
end

# Returns <tt>true</tt> whether <tt>qstring</tt> is registered.
# <tt>qstring</tt> is intended to be a domain name,
# otherwise this method may return unexpected responses.
#
# Whois.registered?("google.com")
# # => true
#
# Whois.registered?("google-is-not-available-try-again-later.com")
# # => false
#
# Warning: this method is only available if a Whois parser exists
# for <tt>qstring</tt> top level domain. Otherwise you'll get a warning message
# and the method will return <tt>nil</tt>.
# This is a technical limitation. Browse the lib/whois/answer/parsers folder
# to view all available parsers.
#
def self.registered?(qstring)
query(qstring).registered?
rescue ParserNotFound => e
$stderr.puts "This method is not available for this kind of object.\n" +
"Use Whois.query('#{qstring}') instead."
nil
end



# See Whois#whois.
def self.query(qstring)
Client.new.query(qstring)
end

end

0 comments on commit 58726ad

Please sign in to comment.