class YAPI::Response
Public Instance Methods
body_str()
click to toggle source
# File lib/yapi/response.rb, line 23 def body_str if self["Content-Type"] =~ /application\/json/ JSON.pretty_generate(JSON.parse(body)).to_s else body.to_s end end
header_str()
click to toggle source
# File lib/yapi/response.rb, line 15 def header_str String.new.tap do |out| headers.each do |k, v| out << "#{k}: #{v}\n" end end end
to_s(show_headers: true)
click to toggle source
# File lib/yapi/response.rb, line 7 def to_s(show_headers: true) String.new.tap do |out| out << "\n#{status}\n\n" out << header_str + "\n" if show_headers out << body_str end end