Sha256: e82075d04b82d02596468480a1bd2cf081e436ab029db4266340b772be82c593

Contents?: true

Size: 1.09 KB

Versions: 18

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8
# 
# 
# 
module Mail
  class ContentDispositionField < StructuredField
    
    FIELD_NAME = 'content-disposition'
    CAPITALIZED_FIELD = 'Content-Disposition'
    
    def initialize(*args)
      super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, args.last))
    end
    
    def tree
      @element ||= Mail::ContentDispositionElement.new(value)
      @tree ||= @element.tree
    end
    
    def element
      @element ||= Mail::ContentDispositionElement.new(value)
    end

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

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

    # TODO: Fix this up
    def encoded
      "#{CAPITALIZED_FIELD}: #{value}\r\n"
    end
    
    def decoded
      value
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mail-1.5.2 lib/mail/fields/content_disposition_field.rb
mail-1.5.1 lib/mail/fields/content_disposition_field.rb
mail-1.5.0 lib/mail/fields/content_disposition_field.rb
mail-1.4.3 lib/mail/fields/content_disposition_field.rb
mail-1.4.2 lib/mail/fields/content_disposition_field.rb
mail-1.4.1 lib/mail/fields/content_disposition_field.rb
mail-1.4.0 lib/mail/fields/content_disposition_field.rb
mail-1.3.5 lib/mail/fields/content_disposition_field.rb
mail-1.3.4 lib/mail/fields/content_disposition_field.rb
mail-1.3.3 lib/mail/fields/content_disposition_field.rb
mail-1.3.2 lib/mail/fields/content_disposition_field.rb
mail-1.3.1 lib/mail/fields/content_disposition_field.rb
mail-1.3.0 lib/mail/fields/content_disposition_field.rb
mail-1.2.9 lib/mail/fields/content_disposition_field.rb
mail-1.2.8 lib/mail/fields/content_disposition_field.rb
mail-1.2.6 lib/mail/fields/content_disposition_field.rb
mail-1.2.5 ./lib/mail/fields/content_disposition_field.rb
mail-1.2.1 ./lib/mail/fields/content_disposition_field.rb