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]  

Public Class methods

new (tool)
[show source]
# File lib/shrine/plugins/determine_mime_type.rb, line 150
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

Public Instance methods

call (io)
[show source]
# File lib/shrine/plugins/determine_mime_type.rb, line 156
def call(io)
  mime_type = send(:"extract_with_#{@tool}", io)
  io.rewind

  mime_type
end