class WebCache::Response
Attributes
base_uri[RW]
code[RW]
content[RW]
error[RW]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/webcache/response.rb, line 5 def initialize(opts = {}) case opts when HTTP::Response then init_with_http_response opts when Hash then init_with_hash opts end end
Public Instance Methods
success?()
click to toggle source
# File lib/webcache/response.rb, line 16 def success? !error end
to_s()
click to toggle source
# File lib/webcache/response.rb, line 12 def to_s content end
Private Instance Methods
init_with_hash(opts)
click to toggle source
# File lib/webcache/response.rb, line 34 def init_with_hash(opts) @error = opts[:error] @base_uri = opts[:base_uri] @content = opts[:content] @code = opts[:code] end
init_with_http_response(response)
click to toggle source
# File lib/webcache/response.rb, line 22 def init_with_http_response(response) @base_uri = response.uri @code = response.code if response.status.success? @content = response.to_s @error = nil else @content = response.status.to_s @error = response.status.to_s end end