class Mail::ContentDispositionField - mail-2.5.4 Documentation

# class Mail::ContentDispositionField

### Constants

CAPITALIZED_FIELD
FIELD_NAME

### Public Class Methods

new(value = nil, charset = 'utf-8') click to toggle source
Calls superclass method

    # File lib/mail/fields/content_disposition_field.rb, line 9
    def initialize(value = nil, charset = 'utf-8')
      self.charset = charset
      ensure_filename_quoted(value)
      super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
      self.parse
      self
    end

### Public Instance Methods

decoded() click to toggle source

    # File lib/mail/fields/content_disposition_field.rb, line 59
    def decoded
      if parameters.length > 0
        p = "; #{parameters.decoded}"
      else
        p = ""
      end
      "#{disposition_type}" + p
    end

disposition_type() click to toggle source

    # File lib/mail/fields/content_disposition_field.rb, line 27
    def disposition_type
      element.disposition_type
    end

element() click to toggle source

    # File lib/mail/fields/content_disposition_field.rb, line 23
    def element
      @element ||= Mail::ContentDispositionElement.new(value)
    end

encoded() click to toggle source

TODO: Fix this up

    # File lib/mail/fields/content_disposition_field.rb, line 50
    def encoded
      if parameters.length > 0
        p = ";\r\n\s#{parameters.encoded}\r\n"
      else
        p = "\r\n"
      end
      "#{CAPITALIZED_FIELD}: #{disposition_type}" + p
    end

filename() click to toggle source

    # File lib/mail/fields/content_disposition_field.rb, line 37
    def filename
      case
      when !parameters['filename'].blank?
        @filename = parameters['filename']
      when !parameters['name'].blank?
        @filename = parameters['name']
      else
        @filename = nil
      end
      @filename
    end

parameters() click to toggle source

    # File lib/mail/fields/content_disposition_field.rb, line 31
    def parameters
      @parameters = ParameterHash.new
      element.parameters.each { |p| @parameters.merge!(p) }
      @parameters
    end

parse(val = value) click to toggle source

    # File lib/mail/fields/content_disposition_field.rb, line 17
    def parse(val = value)
      unless val.blank?
        @element = Mail::ContentDispositionElement.new(val)
      end
    end