Class: Mail::ContentDispositionField

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

Constant Summary collapse

FIELD_NAME =
'content-disposition'
CAPITALIZED_FIELD =
'Content-Disposition'

Instance Method Summary collapse

Methods inherited from StructuredField

#default

Methods included from Utilities

included

Methods included from CommonField

included

Constructor Details

#initialize(*args) ⇒ ContentDispositionField

Returns a new instance of ContentDispositionField.



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

def initialize(*args)
  super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
  self.parse
  self

end

Instance Method Details

#decodedObject



55
56
57
# File 'lib/mail/fields/content_disposition_field.rb', line 55

def decoded
  value
end

#disposition_typeObject



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

def disposition_type
  element.disposition_type
end

#elementObject



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

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

#encodedObject

TODO: Fix this up



51
52
53
# File 'lib/mail/fields/content_disposition_field.rb', line 51

def encoded
  "#{CAPITALIZED_FIELD}: #{value}\r\n"
end

#filenameObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mail/fields/content_disposition_field.rb', line 38

def filename
  case
  when !parameters['filename'].blank?
    @filename = parameters['filename']
  when !parameters['name'].blank?
    @filename = parameters['name']
  else 
    @filename = nil
  end
  @filename
end

#parametersObject



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

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

#parse(val = value) ⇒ Object



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

def parse(val = value)
  unless val.blank?
    @element = Mail::ContentDispositionElement.new(val)
  end
end