Class: SMail::MIME::ContentField::Params

Inherits:
Hash
  • Object
show all
Defined in:
lib/smail/mime/content_fields.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.needs_quoting?(text) ⇒ Boolean

FIXME: These two should probably be moved

Returns:

  • (Boolean)


35
36
37
# File 'lib/smail/mime/content_fields.rb', line 35

def needs_quoting?(text)
  false # FIXME
end

.quote(text) ⇒ Object



39
40
41
# File 'lib/smail/mime/content_fields.rb', line 39

def quote(text)
  "\"#{text}\"" # FIXME
end

Instance Method Details

#to_sObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/smail/mime/content_fields.rb', line 44

def to_s
  if self.empty?
    return ""
  else
    pairs = []
    self.each do |key, value|
      pair = key + '='
      if SMail::MIME::ContentField::Params.needs_quoting?(value)
        pair << SMail::MIME::ContentField::Params.quote(value)
      else
        pair << value
      end
      pairs << pair
    end
  end
  '; ' + pairs.join('; ')
end