Class: Pushbots::Response
- Inherits:
-
Object
- Object
- Pushbots::Response
- Defined in:
- lib/pushbots/response.rb
Overview
Response class
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
- #to_s ⇒ Object
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 |
# File 'lib/pushbots/response.rb', line 6 def initialize(http_response) self.code = http_response.code if http_response.to_s.empty? self. = 'OK' else http_response = JSON.parse(http_response) self. = "#{http_response['code']}: #{http_response['message']}" end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
4 5 6 |
# File 'lib/pushbots/response.rb', line 4 def code @code end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/pushbots/response.rb', line 4 def @message end |
Instance Method Details
#failed? ⇒ Boolean
16 17 18 |
# File 'lib/pushbots/response.rb', line 16 def failed? code != 200 end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/pushbots/response.rb', line 20 def to_s "{code: #{code}, message: #{}}" end |