Sha256: a4311be9e2f913b604a8eed83655295d884f554aff4d79645f9e02d08f3e6723

Contents?: true

Size: 780 Bytes

Versions: 12

Compression:

Stored size: 780 Bytes

Contents

# encoding: utf-8
module Mail
  class ContentTypeElement # :nodoc:
    
    include Mail::Utilities
    
    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
    
    def main_type
      @main_type
    end
    
    def sub_type
      @sub_type
    end
    
    def parameters
      @parameters
    end
    
    def to_s(*args)

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mail-1.3.4 lib/mail/elements/content_type_element.rb
mail-1.3.3 lib/mail/elements/content_type_element.rb
mail-1.3.2 lib/mail/elements/content_type_element.rb
mail-1.3.1 lib/mail/elements/content_type_element.rb
mail-1.3.0 lib/mail/elements/content_type_element.rb
mail-1.2.9 lib/mail/elements/content_type_element.rb
mail-1.2.8 lib/mail/elements/content_type_element.rb
mail-1.2.6 lib/mail/elements/content_type_element.rb
mail-1.2.5 ./lib/mail/elements/content_type_element.rb
mail-1.2.1 ./lib/mail/elements/content_type_element.rb
mail-1.1.0 ./lib/mail/elements/content_type_element.rb
mail-1.0.0 ./lib/mail/elements/content_type_element.rb