Class: ActiveStorage::Filename::Parameters

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#filenameObject (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

#asciiObject



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

#combinedObject



10
11
12
# File 'app/models/active_storage/filename/parameters.rb', line 10

def combined
  "#{ascii}; #{utf8}"
end

#to_sObject



26
27
28
# File 'app/models/active_storage/filename/parameters.rb', line 26

def to_s
  combined
end

#utf8Object



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