Sha256: 4aa5f89cb6af274740e2d7024c9765a202fded98f45a0f188c28454a4d981ada

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
# frozen_string_literal: true
require 'mail/fields/named_structured_field'
require 'mail/fields/parameter_hash'

module Mail
  class ContentDispositionField < NamedStructuredField #:nodoc:
    NAME = 'Content-Disposition'

    def self.singular?
      true
    end

    def initialize(value = nil, charset = nil)
      super ensure_filename_quoted(value), charset
    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) } unless element.parameters.nil?
      @parameters
    end

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

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

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

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/fields/content_disposition_field.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/fields/content_disposition_field.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/fields/content_disposition_field.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/fields/content_disposition_field.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/fields/content_disposition_field.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/fields/content_disposition_field.rb
mail-2.8.1 lib/mail/fields/content_disposition_field.rb
mail-2.8.1.rc2 lib/mail/fields/content_disposition_field.rb
mail-2.8.0.1 lib/mail/fields/content_disposition_field.rb
mail-2.8.0.1.rc1 lib/mail/fields/content_disposition_field.rb
mail-2.8.0 lib/mail/fields/content_disposition_field.rb
mail-2.8.0.rc3 lib/mail/fields/content_disposition_field.rb
mail-2.8.0.rc2 lib/mail/fields/content_disposition_field.rb
mail-2.8.0.rc1 lib/mail/fields/content_disposition_field.rb