Marcel::Magic
Mime type detection
Constants
HTML_MAGIC = [MagicRule.new(0..4096, Regex.new("\\A(?:\\x{FEFF})?[ \\t\\r\\n\\f]*(?:<\\?xml(?:[ \\t\\r\\n\\f]+(?:[^?]|\\?(?!>))*)?\\?>[ \\t\\r\\n\\f]*)?" + "(?:<!--(?:[^-]|-(?!->))*-->[ \\t\\r\\n\\f]*)*(?:<!DOCTYPE[ \\t\\r\\n\\f]+html(?=[ \\t\\r\\n\\f>])|<html(?=[ \\t\\r\\n\\f>]))", :ignore_case))] of MagicRule
XHTML_MAGIC = [MagicRule.new(0..4096, Regex.new((((((((((((((((("\\A" + "(?:\\x{FEFF})?[ \\t\\r\\n\\f]*") + "(?:<\\?xml(?:[ \\t\\r\\n\\f]+(?:[^?]|\\?(?!>))*)?\\?>[ \\t\\r\\n\\f]*)?") + "(?:<!--(?:[^-]|-(?!->))*-->[ \\t\\r\\n\\f]*)*") + "(?:") + "<!DOCTYPE[ \\t\\r\\n\\f]+html(?:[ \\t\\r\\n\\f]+[^>]*)?>[ \\t\\r\\n\\f]*") + "(?:<!--(?:[^-]|-(?!->))*-->[ \\t\\r\\n\\f]*)*") + ")?") + "<html(?=[ \\t\\r\\n\\f>])") + "(?:") + "[ \\t\\r\\n\\f]+") + "(?!xmlns[ \\t\\r\\n\\f]*=)") + "[A-Za-z_:][A-Za-z0-9_.:-]*") + "[ \\t\\r\\n\\f]*=[ \\t\\r\\n\\f]*") + "(?:\"[^\"]*\"|'[^']*')") + ")*") + "[ \\t\\r\\n\\f]+xmlns[ \\t\\r\\n\\f]*=[ \\t\\r\\n\\f]*") + "(?:\"http://www\\.w3\\.org/1999/xhtml\"|'http://www\\.w3\\.org/1999/xhtml')", :extended))] of MagicRule
Constructors
Class methods
add(type : String, extensions : String | Array(String) | Nil = nil, parents : String | Array(String) | Nil = nil, aliases : String | Array(String) | Nil = nil, magic : Array(MagicRule) | Nil = nil)
Add custom mime type. Arguments:
- type: Mime type
- extensions: String or list of file extensions
- parents: String or list of parent mime types
- aliases: String or list of aliased mime types
- magic: Mime magic specification
Lookup all mime types by magic content analysis. This is a slower operation.
Lookup mime type by magic content analysis. This is a slow operation.
Lookup canonical mime type by mime type string, resolving aliases
Resolve an aliased type string to its canonical type string
Renames a canonical type: the instead_of type's extensions, magic matchers, parents, and aliases are re-registered under type, and the old name becomes an alias of the new. Useful when a historical or de facto type is preferable to the canonical type shipped in the generated tables, without giving up its matchers.
Instance methods
audio?
Sourcemediatype
Sourcesubtype
Sourcetype
Sourcevideo?
Source