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.



12
13
14
# File 'lib/mail/fields/content_disposition_field.rb', line 12

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

Class Method Details

.singular?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/mail/fields/content_disposition_field.rb', line 8

def self.singular?
  true
end

Instance Method Details

#decodedObject



39
40
41
42
# File 'lib/mail/fields/content_disposition_field.rb', line 39

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

#disposition_typeObject



20
21
22
# File 'lib/mail/fields/content_disposition_field.rb', line 20

def disposition_type
  element.disposition_type
end

#elementObject



16
17
18
# File 'lib/mail/fields/content_disposition_field.rb', line 16

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

#encodedObject



34
35
36
37
# File 'lib/mail/fields/content_disposition_field.rb', line 34

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

#filenameObject



30
31
32
# File 'lib/mail/fields/content_disposition_field.rb', line 30

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

#parametersObject



24
25
26
27
28
# File 'lib/mail/fields/content_disposition_field.rb', line 24

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