Class: FileValidators::MimeTypeAnalyzer
- Inherits:
-
Object
- Object
- FileValidators::MimeTypeAnalyzer
- Defined in:
- lib/file_validators/mime_type_analyzer.rb
Constant Summary collapse
- SUPPORTED_TOOLS =
%i[fastimage file filemagic mimemagic marcel mime_types mini_mime].freeze
- MAGIC_NUMBER =
256 * 1024
Instance Method Summary collapse
- #call(io) ⇒ Object
-
#initialize(tool) ⇒ MimeTypeAnalyzer
constructor
A new instance of MimeTypeAnalyzer.
Constructor Details
#initialize(tool) ⇒ MimeTypeAnalyzer
Returns a new instance of MimeTypeAnalyzer.
9 10 11 12 13 |
# File 'lib/file_validators/mime_type_analyzer.rb', line 9 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) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/file_validators/mime_type_analyzer.rb', line 15 def call(io) mime_type = send(:"extract_with_#{@tool}", io) io.rewind mime_type end |