class VW::HTTPResult

Attributes

error[RW]
object[RW]
request_method[RW]
request_params[RW]
request_url[RW]
response[RW]

Public Class Methods

new(response, response_object, error) click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 5
def initialize(response, response_object, error)
  @response = response
  @object = response_object
  @error = error
end

Public Instance Methods

body() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 19
def body
  @object.to_s if @object
end
failure?() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 48
def failure?
  !!error
end
headers() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 38
def headers
  if @response
    @_headers ||= @response.headers.inject({}){|h, entry_set| h[entry_set[0]] = entry_set[1] ; h }
  end
end
inspect() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 52
def inspect
  "<VW::HTTPResult:#{self.object_id} #{@request_url}>"
end
method_description() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 23
def method_description
  case @request_method
  when 0
    "GET"
  when 1
    "POST"
  when 2
    "PUT"
  when 3
    "DELETE"
  else
    "Unknown"
  end
end
not_modified?() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 15
def not_modified?
  @response.notModified if @response
end
status_code() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 11
def status_code
  @response.statusCode if @response
end
success?() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 44
def success?
  !failure?
end
to_s() click to toggle source
# File lib/project/volley_wrap/http_result.rb, line 56
    def to_s
      header_string = if (h = headers)
        h.map{|k,v| "  #{k} = #{v}"}.join("\n")
      else
        "none"
      end

      params_string = if @request_params
        @request_params.map{|k,v| "  #{k} = #{v}"}.join("\n")
      else
        "none"
      end

      %(

Request -------------------------

URL: #{@request_url}
Method: #{method_description}
Params:
#{params_string}

Response -------------------------

Status code: #{status_code}
Not modified?: #{not_modified?}
Success: #{success?}

Error: #{error.toString if error}

Headers:
#{header_string}

Body:
#{body}
-----------------------------------

)
    end