Class: Tzispa::Helpers::Services::SendFile
- Inherits:
-
Object
- Object
- Tzispa::Helpers::Services::SendFile
- Defined in:
- lib/tzispa/helpers/services/send_file.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #content_disposition(filename = nil, disposition = 'attachment') ⇒ Object
-
#initialize(response, path, opts) ⇒ SendFile
constructor
A new instance of SendFile.
- #send(result) ⇒ Object
Constructor Details
#initialize(response, path, opts) ⇒ SendFile
Returns a new instance of SendFile.
12 13 14 15 16 |
# File 'lib/tzispa/helpers/services/send_file.rb', line 12 def initialize(response, path, opts) @response = response @opts = opts @path = path end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
10 11 12 |
# File 'lib/tzispa/helpers/services/send_file.rb', line 10 def opts @opts end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/tzispa/helpers/services/send_file.rb', line 10 def path @path end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/tzispa/helpers/services/send_file.rb', line 10 def response @response end |
Instance Method Details
#content_disposition(filename = nil, disposition = 'attachment') ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/tzispa/helpers/services/send_file.rb', line 18 def content_disposition(filename = nil, disposition = 'attachment') disposition = String.new << disposition.to_s if filename escaped = URI.escape(filename) disposition << "; filename=\"#{escaped}\"" disposition << "; filename*=UTF-8''#{escaped}" end response['Content-Disposition'] = disposition end |
#send(result) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/tzispa/helpers/services/send_file.rb', line 28 def send(result) prepare response.status = result[0] if response.status.between? 200, 299 headers_set result[1] response.body = result[2] end response end |