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.



35
36
37
38
39
# File 'lib/utopia/middleware/requester.rb', line 35

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

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



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

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#[](key) ⇒ Object



58
59
60
# File 'lib/utopia/middleware/requester.rb', line 58

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

#bodyObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/utopia/middleware/requester.rb', line 44

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)


62
63
64
# File 'lib/utopia/middleware/requester.rb', line 62

def okay?
	@status == 200
end