Class: Mail::ContentTypeElement

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/mail/elements/content_type_element.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Utilities

included

Constructor Details

#initialize(string) ⇒ ContentTypeElement

Returns a new instance of ContentTypeElement.



7
8
9
10
11
12
13
14
15
16
# File 'lib/mail/elements/content_type_element.rb', line 7

def initialize( string )
  parser = Mail::ContentTypeParser.new
  if tree = parser.parse(cleaned(string))
    @main_type = tree.main_type.text_value
    @sub_type = tree.sub_type.text_value
    @parameters = tree.parameters
  else
    raise Mail::Field::ParseError, "ContentTypeElement can not parse |#{string}|\nReason was: #{parser.failure_reason}\n"
  end
end

Instance Method Details

#cleaned(string) ⇒ Object



30
31
32
# File 'lib/mail/elements/content_type_element.rb', line 30

def cleaned(string)
  string =~ /(.+);\s*$/ ? $1 : string
end

#main_typeObject



18
19
20
# File 'lib/mail/elements/content_type_element.rb', line 18

def main_type
  @main_type
end

#parametersObject



26
27
28
# File 'lib/mail/elements/content_type_element.rb', line 26

def parameters
  @parameters
end

#sub_typeObject



22
23
24
# File 'lib/mail/elements/content_type_element.rb', line 22

def sub_type
  @sub_type
end