Class: Paltrow::Rendering::Rails::ContentDisposition
- Inherits:
-
Object
- Object
- Paltrow::Rendering::Rails::ContentDisposition
- Defined in:
- lib/paltrow/rendering/rails/stream.rb
Overview
:nodoc:
Constant Summary collapse
- TRADITIONAL_ESCAPED_CHAR =
/[^ A-Za-z0-9!\#$+.^_`|~-]/
- RFC_5987_ESCAPED_CHAR =
/[^A-Za-z0-9!\#$&+.^_`|~-]/
Instance Attribute Summary collapse
-
#disposition ⇒ Object
readonly
Returns the value of attribute disposition.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Class Method Summary collapse
Instance Method Summary collapse
- #ascii_filename ⇒ Object
-
#initialize(disposition:, filename:) ⇒ ContentDisposition
constructor
A new instance of ContentDisposition.
- #to_s ⇒ Object
- #utf8_filename ⇒ Object
Constructor Details
#initialize(disposition:, filename:) ⇒ ContentDisposition
Returns a new instance of ContentDisposition.
13 14 15 16 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 13 def initialize disposition:, filename: @disposition = disposition @filename = filename end |
Instance Attribute Details
#disposition ⇒ Object (readonly)
Returns the value of attribute disposition.
11 12 13 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 11 def disposition @disposition end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
11 12 13 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 11 def filename @filename end |
Class Method Details
.format(disposition:, filename:) ⇒ Object
7 8 9 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 7 def self.format disposition:, filename: new(disposition: disposition, filename: filename).to_s end |
Instance Method Details
#ascii_filename ⇒ Object
20 21 22 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 20 def ascii_filename 'filename="' + percent_escape(I18n.transliterate(filename), TRADITIONAL_ESCAPED_CHAR) + '"' end |
#to_s ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 30 def to_s if filename "#{disposition}; #{ascii_filename}; #{utf8_filename}" else disposition.to_s end end |
#utf8_filename ⇒ Object
26 27 28 |
# File 'lib/paltrow/rendering/rails/stream.rb', line 26 def utf8_filename "filename*=UTF-8''" + percent_escape(filename, RFC_5987_ESCAPED_CHAR) end |