Class: Shrine::Plugins::DetermineMimeType::MimeTypeAnalyzer
- Inherits:
-
Object
- Object
- Shrine::Plugins::DetermineMimeType::MimeTypeAnalyzer
- Defined in:
- lib/shrine/plugins/determine_mime_type.rb
Constant Summary collapse
- SUPPORTED_TOOLS =
[:fastimage, :file, :filemagic, :mimemagic, :marcel, :mime_types, :mini_mime, :content_type]
- MAGIC_NUMBER =
256 * 1024
Instance Method Summary collapse
- #call(io, options = {}) ⇒ Object
-
#initialize(tool) ⇒ MimeTypeAnalyzer
constructor
A new instance of MimeTypeAnalyzer.
Constructor Details
#initialize(tool) ⇒ MimeTypeAnalyzer
Returns a new instance of MimeTypeAnalyzer.
93 94 95 96 97 |
# File 'lib/shrine/plugins/determine_mime_type.rb', line 93 def initialize(tool) raise Error, "unknown mime type analyzer #{tool.inspect}, supported analyzers are: #{SUPPORTED_TOOLS.join(",")}" unless SUPPORTED_TOOLS.include?(tool) @tool = tool end |
Instance Method Details
#call(io, options = {}) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/shrine/plugins/determine_mime_type.rb', line 99 def call(io, = {}) mime_type = send(:"extract_with_#{@tool}", io, ) io.rewind mime_type end |