Class: RoboWhois

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/robo_whois.rb,
lib/robo_whois/version.rb

Defined Under Namespace

Modules: Version Classes: APIError, Error

Constant Summary collapse

VERSION =

The current library version.

Version::STRING

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RoboWhois

Returns a new instance of RoboWhois.

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
# File 'lib/robo_whois.rb', line 48

def initialize(options = {})
  options[:api_key] = (options[:api_key] || ENV["ROBOWHOIS_API_KEY"]).to_s

  raise ArgumentError, "Missing API key" if options[:api_key].empty?

  @auth = { :username => options[:api_key], :password => "X" }
end

Instance Attribute Details

#last_responseHTTParty::Response (readonly)

Returns The response object returned by the last API call.

Returns:

  • (HTTParty::Response)

    The response object returned by the last API call.



45
46
47
# File 'lib/robo_whois.rb', line 45

def last_response
  @last_response
end

Class Method Details

.deprecate(message = nil) ⇒ void

This method returns an undefined value.

Echoes a deprecation warning message.

Parameters:

  • message (String) (defaults to: nil)

    The message to display.



36
37
38
39
# File 'lib/robo_whois.rb', line 36

def self.deprecate(message = nil)
  message ||= "You are using deprecated behavior which will be removed from the next major or minor release."
  warn("DEPRECATION WARNING: #{message}")
end

Instance Method Details

#accountObject



64
65
66
# File 'lib/robo_whois.rb', line 64

def 
  get("/account")["account"]
end

#api_keyString

Gets the current API key.

Returns:

  • (String)


59
60
61
# File 'lib/robo_whois.rb', line 59

def api_key
  @auth[:username]
end

#availability(query) ⇒ Object



85
86
87
# File 'lib/robo_whois.rb', line 85

def availability(query)
  get("/availability/#{query}")["response"]
end

#whois(query) ⇒ Object



69
70
71
# File 'lib/robo_whois.rb', line 69

def whois(query)
  get("/whois/#{query}")
end

#whois_parts(query) ⇒ Object



73
74
75
# File 'lib/robo_whois.rb', line 73

def whois_parts(query)
  get("/whois/#{query}/parts")["response"]
end

#whois_properties(query) ⇒ Object



77
78
79
# File 'lib/robo_whois.rb', line 77

def whois_properties(query)
  get("/whois/#{query}/properties")["response"]
end

#whois_record(query) ⇒ Object



81
82
83
# File 'lib/robo_whois.rb', line 81

def whois_record(query)
  get("/whois/#{query}/record")["response"]
end