Class: Mail::ContentDispositionField

Inherits:
NamedStructuredField show all
Defined in:
lib/mail/fields/content_disposition_field.rb

Overview

:nodoc:

Constant Summary collapse

NAME =
'Content-Disposition'

Instance Attribute Summary

Attributes inherited from CommonField

#charset, #errors, #name, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommonField

#default, #parse, parse, #responsible_for?, #singular?, #to_s

Constructor Details

#initialize(value = nil, charset = nil) ⇒ ContentDispositionField

Returns a new instance of ContentDispositionField.



14
15
16
# File 'lib/mail/fields/content_disposition_field.rb', line 14

def initialize(value = nil, charset = nil)
  super ensure_filename_quoted(value), charset
end

Class Method Details

.singular?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/mail/fields/content_disposition_field.rb', line 10

def self.singular?
  true
end

Instance Method Details

#decodedObject



41
42
43
44
# File 'lib/mail/fields/content_disposition_field.rb', line 41

def decoded
  p = "; #{parameters.decoded}" if parameters.length > 0
  "#{disposition_type}#{p}"
end

#disposition_typeObject



22
23
24
# File 'lib/mail/fields/content_disposition_field.rb', line 22

def disposition_type
  element.disposition_type
end

#elementObject



18
19
20
# File 'lib/mail/fields/content_disposition_field.rb', line 18

def element
  @element ||= Mail::ContentDispositionElement.new(value)
end

#encodedObject



36
37
38
39
# File 'lib/mail/fields/content_disposition_field.rb', line 36

def encoded
  p = ";\r\n\s#{parameters.encoded}" if parameters.length > 0
  "#{name}: #{disposition_type}#{p}\r\n"
end

#filenameObject



32
33
34
# File 'lib/mail/fields/content_disposition_field.rb', line 32

def filename
  @filename ||= parameters['filename'] || parameters['name']
end

#parametersObject



26
27
28
29
30
# File 'lib/mail/fields/content_disposition_field.rb', line 26

def parameters
  @parameters = ParameterHash.new
  element.parameters.each { |p| @parameters.merge!(p) } unless element.parameters.nil?
  @parameters
end