Class: Dailycred::Response
- Inherits:
-
Object
- Object
- Dailycred::Response
- Defined in:
- lib/dailycred/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#json ⇒ Object
Returns the value of attribute json.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #errors ⇒ Object
- #errors? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #user ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 |
# File 'lib/dailycred/response.rb', line 6 def initialize response @body = response.body @json = JSON.parse(@body) @headers = response.headers @status = response.status end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/dailycred/response.rb', line 4 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/dailycred/response.rb', line 4 def headers @headers end |
#json ⇒ Object
Returns the value of attribute json.
4 5 6 |
# File 'lib/dailycred/response.rb', line 4 def json @json end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/dailycred/response.rb', line 4 def status @status end |
Instance Method Details
#errors ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/dailycred/response.rb', line 21 def errors begin json["errors"][0] rescue nil end end |
#errors? ⇒ Boolean
13 14 15 |
# File 'lib/dailycred/response.rb', line 13 def errors? json["worked"] != true end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/dailycred/response.rb', line 17 def success? @status == 200 && json["worked"] == true end |
#user ⇒ Object
29 30 31 |
# File 'lib/dailycred/response.rb', line 29 def user json["user"] end |