Class: Utopia::Middleware::Requester::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/middleware/requester.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ Response

Returns a new instance of Response.



19
20
21
22
23
# File 'lib/utopia/middleware/requester.rb', line 19

def initialize(status, headers, body)
	@status = status
	@headers = headers
	@body = body
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



26
27
28
# File 'lib/utopia/middleware/requester.rb', line 26

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



25
26
27
# File 'lib/utopia/middleware/requester.rb', line 25

def status
  @status
end

Instance Method Details

#[](key) ⇒ Object



42
43
44
# File 'lib/utopia/middleware/requester.rb', line 42

def [](key)
	return @headers[key]
end

#bodyObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/utopia/middleware/requester.rb', line 28

def body
	unless @body_string
		buffer = StringIO.new

		@body.each do |string|
			buffer.write(string)
		end

		@body_string = buffer.string
	end

	return @body_string
end

#okay?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/utopia/middleware/requester.rb', line 46

def okay?
	@status == 200
end