Class: Cpanel::Response
- Inherits:
-
Object
- Object
- Cpanel::Response
- Defined in:
- lib/cpanel/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cpanel/response.rb', line 7 def initialize(response) response = ActiveSupport::JSON.decode(response) if response["result"] @response = response["result"][0] ? response["result"][0] : response["result"] else @response = response end @success = success? end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/cpanel/response.rb', line 5 def response @response end |
#success ⇒ Object
Returns the value of attribute success.
5 6 7 |
# File 'lib/cpanel/response.rb', line 5 def success @success end |
Instance Method Details
#errors ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/cpanel/response.rb', line 19 def errors if success? nil else return response["statusmsg"] ? response["statusmsg"] : nil end end |
#success? ⇒ Boolean
27 28 29 |
# File 'lib/cpanel/response.rb', line 27 def success? return response["status"] ? response["status"] == 1 : true end |