Class: Crystal::Response
- Defined in:
- lib/crystal/http/support/rack/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #content_type ⇒ Object
- #content_type=(type) ⇒ Object
- #content_type? ⇒ Boolean
- #empty? ⇒ Boolean (also: #blank?)
-
#initialize ⇒ Response
constructor
attr_accessor :error # for specs.
- #inspect ⇒ Object
- #location ⇒ Object
- #location=(location) ⇒ Object
- #to_a ⇒ Object
- #write(str) ⇒ Object
Constructor Details
#initialize ⇒ Response
attr_accessor :error # for specs
6 7 8 |
# File 'lib/crystal/http/support/rack/response.rb', line 6 def initialize @status, @headers, @body = 200, {}, "" end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/crystal/http/support/rack/response.rb', line 3 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/crystal/http/support/rack/response.rb', line 3 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/crystal/http/support/rack/response.rb', line 3 def status @status end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/crystal/http/support/rack/response.rb', line 29 def == other super(other) || to_a == other end |
#content_type ⇒ Object
15 |
# File 'lib/crystal/http/support/rack/response.rb', line 15 def content_type; headers["Content-Type"] end |
#content_type=(type) ⇒ Object
14 |
# File 'lib/crystal/http/support/rack/response.rb', line 14 def content_type= type; headers["Content-Type"] = type end |
#content_type? ⇒ Boolean
16 |
# File 'lib/crystal/http/support/rack/response.rb', line 16 def content_type?; !!content_type end |
#empty? ⇒ Boolean Also known as: blank?
33 34 35 |
# File 'lib/crystal/http/support/rack/response.rb', line 33 def empty? body.empty? end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/crystal/http/support/rack/response.rb', line 25 def inspect to_a.inspect end |
#location ⇒ Object
18 |
# File 'lib/crystal/http/support/rack/response.rb', line 18 def location; headers['Location'] end |
#location=(location) ⇒ Object
19 |
# File 'lib/crystal/http/support/rack/response.rb', line 19 def location= location; headers['Location'] = location end |
#to_a ⇒ Object
21 22 23 |
# File 'lib/crystal/http/support/rack/response.rb', line 21 def to_a [status, headers, body] end |
#write(str) ⇒ Object
10 11 12 |
# File 'lib/crystal/http/support/rack/response.rb', line 10 def write str body << str end |