Class: Resizor::Response
- Inherits:
-
Object
- Object
- Resizor::Response
- Defined in:
- lib/resizor/connection.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
-
#format ⇒ Object
Returns the value of attribute format.
Instance Method Summary collapse
-
#initialize(_code, _body, _format = 'json') ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(_code, _body, _format = 'json') ⇒ Response
Returns a new instance of Response.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/resizor/connection.rb', line 66 def initialize(_code, _body, _format = 'json') @code = _code @format = _format @body = _body.to_s.strip @body = if @format == 'json' && @body != '' if defined?(ActiveSupport::JSON) ActiveSupport::JSON.decode(@body) else JSON.parse(@body) end else _body end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
65 66 67 |
# File 'lib/resizor/connection.rb', line 65 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
65 66 67 |
# File 'lib/resizor/connection.rb', line 65 def code @code end |
#format ⇒ Object
Returns the value of attribute format.
65 66 67 |
# File 'lib/resizor/connection.rb', line 65 def format @format end |