Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vistahigherlearning / logstash   deb

Repository URL to install this package:

/ opt / logstash / vendor / bundle / jruby / 1.9 / gems / mail-2.5.3 / lib / mail / elements / content_type_element.rb

# 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.downcase
        @sub_type = tree.sub_type.text_value.downcase
        @parameters = tree.parameters
      else
        raise Mail::Field::ParseError.new(ContentTypeElement, string, parser.failure_reason)
      end
    end
    
    def main_type
      @main_type
    end
    
    def sub_type
      @sub_type
    end
    
    def parameters
      @parameters
    end
    
    def cleaned(string)
      string =~ /(.+);\s*$/ ? $1 : string
    end
    
  end
end