Class: VW::HTTPResult
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#object ⇒ Object
Returns the value of attribute object.
-
#request_method ⇒ Object
Returns the value of attribute request_method.
-
#request_params ⇒ Object
Returns the value of attribute request_params.
-
#request_url ⇒ Object
Returns the value of attribute request_url.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #failure? ⇒ Boolean
- #headers ⇒ Object
-
#initialize(response, response_object, error) ⇒ HTTPResult
constructor
A new instance of HTTPResult.
- #inspect ⇒ Object
- #method_description ⇒ Object
- #not_modified? ⇒ Boolean
- #status_code ⇒ Object
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(response, response_object, error) ⇒ HTTPResult
Returns a new instance of HTTPResult.
5 6 7 8 9 |
# File 'lib/project/volley_wrap/http_result.rb', line 5 def initialize(response, response_object, error) @response = response @object = response_object @error = error end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
3 4 5 |
# File 'lib/project/volley_wrap/http_result.rb', line 3 def error @error end |
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/project/volley_wrap/http_result.rb', line 3 def object @object end |
#request_method ⇒ Object
Returns the value of attribute request_method.
3 4 5 |
# File 'lib/project/volley_wrap/http_result.rb', line 3 def request_method @request_method end |
#request_params ⇒ Object
Returns the value of attribute request_params.
3 4 5 |
# File 'lib/project/volley_wrap/http_result.rb', line 3 def request_params @request_params end |
#request_url ⇒ Object
Returns the value of attribute request_url.
3 4 5 |
# File 'lib/project/volley_wrap/http_result.rb', line 3 def request_url @request_url end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/project/volley_wrap/http_result.rb', line 3 def response @response end |
Instance Method Details
#body ⇒ Object
19 20 21 |
# File 'lib/project/volley_wrap/http_result.rb', line 19 def body @object.to_s if @object end |
#failure? ⇒ Boolean
48 49 50 |
# File 'lib/project/volley_wrap/http_result.rb', line 48 def failure? !!error end |
#headers ⇒ Object
38 39 40 41 42 |
# 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 ⇒ Object
52 53 54 |
# File 'lib/project/volley_wrap/http_result.rb', line 52 def inspect "<VW::HTTPResult:#{self.object_id} #{@request_url}>" end |
#method_description ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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? ⇒ Boolean
15 16 17 |
# File 'lib/project/volley_wrap/http_result.rb', line 15 def not_modified? @response.notModified if @response end |
#status_code ⇒ Object
11 12 13 |
# File 'lib/project/volley_wrap/http_result.rb', line 11 def status_code @response.statusCode if @response end |
#success? ⇒ Boolean
44 45 46 |
# File 'lib/project/volley_wrap/http_result.rb', line 44 def success? !failure? end |
#to_s ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# 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 |