Class: Gooru::Response
- Inherits:
-
Object
- Object
- Gooru::Response
- Defined in:
- lib/gooru/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #error_message ⇒ Object
-
#initialize(weary_response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(weary_response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 |
# File 'lib/gooru/response.rb', line 6 def initialize(weary_response) @data = parse(weary_response.body) @status = weary_response.status end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/gooru/response.rb', line 3 def data @data end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/gooru/response.rb', line 4 def status @status end |
Instance Method Details
#error? ⇒ Boolean
11 12 13 14 |
# File 'lib/gooru/response.rb', line 11 def error? has_error_key? || internal_server_error? end |
#error_message ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/gooru/response.rb', line 16 def if has_error_key? data["error"] elsif internal_server_error? data["status"] else "" end end |
#success? ⇒ Boolean
26 27 28 |
# File 'lib/gooru/response.rb', line 26 def success? !error? end |