Class: RoboWhois
- Inherits:
-
Object
- Object
- RoboWhois
- Includes:
- HTTParty
- Defined in:
- lib/robo_whois.rb,
lib/robo_whois/version.rb
Defined Under Namespace
Modules: Version Classes: APIError, Error
Constant Summary collapse
Instance Attribute Summary collapse
-
#last_response ⇒ HTTParty::Response
readonly
The response object returned by the last API call.
Class Method Summary collapse
-
.deprecate(message = nil) ⇒ void
Echoes a deprecation warning message.
Instance Method Summary collapse
- #account ⇒ Object
-
#api_key ⇒ String
Gets the current API key.
- #availability(query) ⇒ Object
-
#initialize(options = {}) ⇒ RoboWhois
constructor
A new instance of RoboWhois.
- #whois(query) ⇒ Object
- #whois_parts(query) ⇒ Object
- #whois_properties(query) ⇒ Object
- #whois_record(query) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RoboWhois
Returns a new instance of RoboWhois.
48 49 50 51 52 53 54 |
# File 'lib/robo_whois.rb', line 48 def initialize( = {}) [:api_key] = ([:api_key] || ENV["ROBOWHOIS_API_KEY"]).to_s raise ArgumentError, "Missing API key" if [:api_key].empty? @auth = { :username => [:api_key], :password => "X" } end |
Instance Attribute Details
#last_response ⇒ HTTParty::Response (readonly)
Returns 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.
36 37 38 39 |
# File 'lib/robo_whois.rb', line 36 def self.deprecate( = nil) ||= "You are using deprecated behavior which will be removed from the next major or minor release." warn("DEPRECATION WARNING: #{}") end |
Instance Method Details
#account ⇒ Object
64 65 66 |
# File 'lib/robo_whois.rb', line 64 def account get("/account")["account"] end |
#api_key ⇒ String
Gets the current API key.
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 |