Class: Mail::ContentDisposition

Inherits:
Object
  • Object
show all
Defined in:
lib/mail/content_disposition.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ ContentDisposition



3
4
5
6
7
8
9
10
11
12
# File 'lib/mail/content_disposition.rb', line 3

def initialize(options = nil)
  @params = Hash.new
  if options
    if options.kind_of?(Hash)
      @type = options[:type]
    elsif options.kind_of?(String)
      set_params(options)
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/mail/content_disposition.rb', line 35

def method_missing(name, *args, &block)
  if name.to_s.include?("=")
    @params[name.to_s.delete("=").to_sym] = args.to_s
  else
    return @params[name]
  end
end

Instance Method Details

#to_sObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mail/content_disposition.rb', line 14

def to_s
  @content_type_str = String.new
  @params.each do |key, value|
    case key
    when :type
      @content_type_str << "Content-Type: #{type};"
    else
      @content_type_str << " #{key}=#{value}\n"
    end
  end
  return @content_type_str
end

#typeObject



31
32
33
# File 'lib/mail/content_disposition.rb', line 31

def type
  return @params[:type]
end

#type=(value) ⇒ Object



27
28
29
# File 'lib/mail/content_disposition.rb', line 27

def type=(value)
  @params[:type] = value
end