Class: ActionTexter::Response
- Inherits:
-
Object
- Object
- ActionTexter::Response
- Defined in:
- lib/action_texter/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#net_http_response ⇒ Object
readonly
Returns the value of attribute net_http_response.
Instance Method Summary collapse
- #error ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(net_http_response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(net_http_response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 |
# File 'lib/action_texter/response.rb', line 5 def initialize(net_http_response) @net_http_response = net_http_response @body = @net_http_response.body @code = @net_http_response.code end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/action_texter/response.rb', line 3 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/action_texter/response.rb', line 3 def code @code end |
#net_http_response ⇒ Object (readonly)
Returns the value of attribute net_http_response.
3 4 5 |
# File 'lib/action_texter/response.rb', line 3 def net_http_response @net_http_response end |
Instance Method Details
#error ⇒ Object
19 20 21 |
# File 'lib/action_texter/response.rb', line 19 def error body.sub('Error: ERROR', '').strip end |
#failure? ⇒ Boolean
15 16 17 |
# File 'lib/action_texter/response.rb', line 15 def failure? !success? end |
#success? ⇒ Boolean
11 12 13 |
# File 'lib/action_texter/response.rb', line 11 def success? body.to_s.strip.empty? && code.to_i == 200 end |