Class: SMail::MIME::ContentField

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

Direct Known Subclasses

ContentDisposition, ContentType

Defined Under Namespace

Classes: Params

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text = nil) ⇒ ContentField

Returns a new instance of ContentField.



10
11
12
13
14
15
16
# File 'lib/smail/mime/content_fields.rb', line 10

def initialize(text = nil)
  @params = Params.new
  unless text.nil?
    (@type_raw, params_raw) = SMail::MIME.decode_content_field(text)
    @params.replace(params_raw)
  end
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/smail/mime/content_fields.rb', line 8

def params
  @params
end

#type_rawObject

The raw type as parsed from the message.



7
8
9
# File 'lib/smail/mime/content_fields.rb', line 7

def type_raw
  @type_raw
end

Instance Method Details

#to_sObject

Returns the Content Field as a string suitable for inclusion in an email header.



28
29
30
# File 'lib/smail/mime/content_fields.rb', line 28

def to_s
  "#{@type_raw}#{self.params.to_s}"
end

#typeObject

Returns the type as a lower case string



19
20
21
# File 'lib/smail/mime/content_fields.rb', line 19

def type
  @type_raw.nil? ? @type_raw : @type_raw.downcase
end

#type=(text) ⇒ Object



23
24
25
# File 'lib/smail/mime/content_fields.rb', line 23

def type=(text)
  @type_raw = text
end