class MyTargetApi::ResponseFormatter
Format response
Attributes
response[R]
Public Class Methods
new(response)
click to toggle source
# File lib/my_target_api/response_formatter.rb, line 9 def initialize(response) @response = response end
Public Instance Methods
format()
click to toggle source
# File lib/my_target_api/response_formatter.rb, line 13 def format headers = response.headers.empty? ? ' No headers' : "\n#{headers_in_lines}" body = response.body.to_s == '' ? ' No body' : "\n#{response.body}" <<~RESPONSE HTTP Code: #{response.code} HTTP Body:#{body} HTTP Headers:#{headers} RESPONSE end
Private Instance Methods
headers()
click to toggle source
# File lib/my_target_api/response_formatter.rb, line 33 def headers @_headers ||= response.headers end
headers_in_lines()
click to toggle source
# File lib/my_target_api/response_formatter.rb, line 27 def headers_in_lines headers.map do |name, value| "#{name}: #{value}" end.join("\n") end