class Shrine::Plugins::DetermineMimeType::MimeTypeAnalyzer

  1. lib/shrine/plugins/determine_mime_type.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. call

Constants

MAGIC_NUMBER = 256 * 1024  
SUPPORTED_TOOLS = [:fastimage, :file, :filemagic, :mimemagic, :marcel, :mime_types, :mini_mime, :content_type]  

Public Class methods

new(tool)
[show source]
   # File lib/shrine/plugins/determine_mime_type.rb
79 def initialize(tool)
80   raise Error, "unknown mime type analyzer #{tool.inspect}, supported analyzers are: #{SUPPORTED_TOOLS.join(",")}" unless SUPPORTED_TOOLS.include?(tool)
81 
82   @tool = tool
83 end

Public Instance methods

call(io, options = {})
[show source]
   # File lib/shrine/plugins/determine_mime_type.rb
85 def call(io, options = {})
86   mime_type = send(:"extract_with_#{@tool}", io, options)
87   io.rewind
88 
89   mime_type
90 end