Class: Resizor::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/resizor/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

Returns the value of attribute body.



65
66
67
# File 'lib/resizor/connection.rb', line 65

def body
  @body
end

#codeObject

Returns the value of attribute code.



65
66
67
# File 'lib/resizor/connection.rb', line 65

def code
  @code
end

#formatObject

Returns the value of attribute format.



65
66
67
# File 'lib/resizor/connection.rb', line 65

def format
  @format
end