Class: Mail::ContentTypeElement
- Inherits:
-
Object
- Object
- Mail::ContentTypeElement
- Includes:
- Utilities
- Defined in:
- lib/mail/elements/content_type_element.rb
Overview
:nodoc:
Instance Method Summary collapse
- #cleaned(string) ⇒ Object
-
#initialize(string) ⇒ ContentTypeElement
constructor
A new instance of ContentTypeElement.
- #main_type ⇒ Object
- #parameters ⇒ Object
- #sub_type ⇒ Object
Methods included from Utilities
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_type ⇒ Object
18 19 20 |
# File 'lib/mail/elements/content_type_element.rb', line 18 def main_type @main_type end |
#parameters ⇒ Object
26 27 28 |
# File 'lib/mail/elements/content_type_element.rb', line 26 def parameters @parameters end |
#sub_type ⇒ Object
22 23 24 |
# File 'lib/mail/elements/content_type_element.rb', line 22 def sub_type @sub_type end |