Creates a MIME::Type from a hash. Keys are case-insensitive,
        dashes may be replaced with underscores, and the internal
        Symbol of the lowercase-underscore version can be used as
        well. That is, Content-Type can be provided as content-type,
        Content_Type, content_type, or :content_type.
        Known keys are <tt>Content-Type</tt>,
        <tt>Content-Transfer-Encoding</tt>, <tt>Extensions</tt>, and
        <tt>System</tt>.
          Type.from_hash({'Content-Type': 'text/x-yaml',
                          'Content-Transfer-Encoding': '8bit',
                          'System': 'linux',
                          'Extensions': ['yaml', 'yml']})
        This is equivalent to:
          t = Type.new('text/x-yaml')
          t.encoding = '8bit'
          t.system = 'linux'
          t.extensions = ['yaml', 'yml']

def from_hash(cls, hash):
        """
        Creates a MIME::Type from a hash. Keys are case-insensitive,
        dashes may be replaced with underscores, and the internal
        Symbol of the lowercase-underscore version can be used as
        well. That is, Content-Type can be provided as content-type,
        Content_Type, content_type, or :content_type.
        Known keys are <tt>Content-Type</tt>,
        <tt>Content-Transfer-Encoding</tt>, <tt>Extensions</tt>, and
        <tt>System</tt>.
          Type.from_hash({'Content-Type': 'text/x-yaml',
                          'Content-Transfer-Encoding': '8bit',
                          'System': 'linux',
                          'Extensions': ['yaml', 'yml']})
        This is equivalent to:
          t = Type.new('text/x-yaml')
          t.encoding = '8bit'
          t.system = 'linux'
          t.extensions = ['yaml', 'yml']
        """
        wrap_key = lambda k: k.lower().replace('-', '_')
        type_hash = dict([(wrap_key(k), v) for k, v in hash.items()])
        mt = cls(type_hash['content_type'])
        mt.extensions = type_hash.get('extensions', [])
        mt.encoding = type_hash.get('encoding', 'default')
        mt.system = type_hash.get('system')
        mt.is_obsolete = type_hash.get('is_obsolete', False)
        mt.docs = type_hash.get('docs')
        mt.url = type_hash.get('url')
        mt.registered = type_hash.get('is_registered', False)
        return mt