class MistFilesResponse

Attributes

body[RW]
code[RW]
headers[RW]

Public Class Methods

new(opts={}) click to toggle source

takes a Net::HTTPResponse

# File lib/mistfiles/send_request.rb, line 12
def initialize(opts={})
              @res = opts[:response]
  @json = opts[:parse_json]
  @code = @res.code.to_i
  @headers = Hash[@res.to_hash.map{ |k,v| [k,(v.first rescue v)] }]
              @body = @res.body || ""
              @body = JSON.parse @res.body if @json && !@body.empty?
end

Public Instance Methods

to_rack() click to toggle source
# File lib/mistfiles/send_request.rb, line 21
def to_rack
  [@code, @headers, (@json ? @body.to_json : @body)]
end