Class: ActiveStorage::Filename::Parameters
- Inherits:
-
Object
- Object
- ActiveStorage::Filename::Parameters
- Defined in:
- app/models/active_storage/filename/parameters.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
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #ascii ⇒ Object
- #combined ⇒ Object
-
#initialize(filename) ⇒ Parameters
constructor
A new instance of Parameters.
- #to_s ⇒ Object
- #utf8 ⇒ Object
Constructor Details
#initialize(filename) ⇒ Parameters
Returns a new instance of Parameters.
6 7 8 |
# File 'app/models/active_storage/filename/parameters.rb', line 6 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'app/models/active_storage/filename/parameters.rb', line 4 def filename @filename end |
Instance Method Details
#ascii ⇒ Object
16 17 18 |
# File 'app/models/active_storage/filename/parameters.rb', line 16 def ascii 'filename="' + percent_escape(I18n.transliterate(filename.sanitized), TRADITIONAL_ESCAPED_CHAR) + '"' end |
#combined ⇒ Object
10 11 12 |
# File 'app/models/active_storage/filename/parameters.rb', line 10 def combined "#{ascii}; #{utf8}" end |
#to_s ⇒ Object
26 27 28 |
# File 'app/models/active_storage/filename/parameters.rb', line 26 def to_s combined end |
#utf8 ⇒ Object
22 23 24 |
# File 'app/models/active_storage/filename/parameters.rb', line 22 def utf8 "filename*=UTF-8''" + percent_escape(filename.sanitized, RFC_5987_ESCAPED_CHAR) end |