Class: WebCache::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/webcache/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/webcache/response.rb', line 5

def initialize(opts={})
  if opts.respond_to?(:read) && opts.respond_to?(:base_uri)
    self.content  = opts.read
    self.base_uri = opts.base_uri
    self.error    = nil
  elsif opts.is_a? Hash
    self.error    = opts[:error]    if opts[:error]
    self.base_uri = opts[:base_uri] if opts[:base_uri]
    self.content  = opts[:content]  if opts[:content]
  end
end

Instance Attribute Details

#base_uriObject

Returns the value of attribute base_uri.



3
4
5
# File 'lib/webcache/response.rb', line 3

def base_uri
  @base_uri
end

#contentObject

Returns the value of attribute content.



3
4
5
# File 'lib/webcache/response.rb', line 3

def content
  @content
end

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/webcache/response.rb', line 3

def error
  @error
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/webcache/response.rb', line 17

def to_s
  content
end