Parent

Included Modules

Class Index [+]

Quicksearch

Mail::ParameterHash

ParameterHash is an intelligent Hash that allows you to add parameter values including the MIME extension paramaters that have the name*0=“blah”, name*1=“bleh” keys, and will just return a single key called name=“blahbleh” and do any required un-encoding to make that happen Parameters are defined in RFC2045, split keys are in RFC2231

Public Instance Methods

[](key_name) click to toggle source
    # File lib/mail/fields/common/parameter_hash.rb, line 15
15:     def [](key_name)
16:       key_pattern = Regexp.escape(key_name.to_s)
17:       pairs = []
18:       exact = nil
19:       each do |k,v|
20:         if k =~ /^#{key_pattern}(\*|$)/
21:           if $1 == '*'
22:             pairs << [k, v]
23:           else
24:             exact = k
25:           end
26:         end
27:       end
28:       if pairs.empty? # Just dealing with a single value pair
29:         super(exact || key_name)
30:       else # Dealing with a multiple value pair or a single encoded value pair
31:         string = pairs.sort { |a,b| a.first <=> b.first }.map { |v| v.last }.join('')
32:         if mt = string.match(/([\w\d\-]+)'(\w\w)'(.*)/)
33:           string = mt[3]
34:           encoding = mt[1]
35:         else
36:           encoding = nil
37:         end
38:         Mail::Encodings.param_decode(string, encoding)
39:       end
40:     end
decoded() click to toggle source
    # File lib/mail/fields/common/parameter_hash.rb, line 52
52:     def decoded
53:       map.sort { |a,b| a.first <=> b.first }.map do |key_name, value|
54:         %{#{key_name}=#{quote_token(value)}}
55:       end.join("; ")
56:     end
encoded() click to toggle source
    # File lib/mail/fields/common/parameter_hash.rb, line 42
42:     def encoded
43:       map.sort { |a,b| a.first <=> b.first }.map do |key_name, value|
44:         unless value.ascii_only?
45:           value = Mail::Encodings.param_encode(value)
46:           key_name = "#{key_name}*"
47:         end
48:         %{#{key_name}=#{quote_token(value)}}
49:       end.join(";\r\n\s")
50:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.