Class: Rstreamor::Response
- Inherits:
-
Object
- Object
- Rstreamor::Response
- Defined in:
- lib/rstreamor/response.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
- #accept_ranges ⇒ Object
- #cache_control ⇒ Object
- #content_length ⇒ Object
- #content_range ⇒ Object
-
#initialize(request) ⇒ Response
constructor
A new instance of Response.
- #response_code ⇒ Object
Constructor Details
#initialize(request) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/rstreamor/response.rb', line 5 def initialize(request) self.request = request end |
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
3 4 5 |
# File 'lib/rstreamor/response.rb', line 3 def request @request end |
Instance Method Details
#accept_ranges ⇒ Object
25 26 27 |
# File 'lib/rstreamor/response.rb', line 25 def accept_ranges 'bytes' end |
#cache_control ⇒ Object
29 30 31 |
# File 'lib/rstreamor/response.rb', line 29 def cache_control 'no-cache' end |
#content_length ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rstreamor/response.rb', line 13 def content_length if self.request.range_header? (self.request.upper_bound - self.request.lower_bound).to_s else self.request.file.data.size end end |
#content_range ⇒ Object
21 22 23 |
# File 'lib/rstreamor/response.rb', line 21 def content_range "bytes #{self.request.lower_bound}-#{self.request.upper_bound - 1}/#{self.request.file.data.size}" end |
#response_code ⇒ Object
9 10 11 |
# File 'lib/rstreamor/response.rb', line 9 def response_code self.request.range_header? ? 206 : 200 end |