class Shrine::Plugins::InferExtension::ExtensionInferrer

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

Methods

Public Class

  1. new

Public Instance

  1. call

Constants

SUPPORTED_TOOLS = [:mime_types, :mini_mime]  

Public Class methods

new(tool)
[show source]
   # File lib/shrine/plugins/infer_extension.rb
75 def initialize(tool)
76   raise Error, "unknown extension inferrer #{tool.inspect}, supported inferrers are: #{SUPPORTED_TOOLS.join(",")}" unless SUPPORTED_TOOLS.include?(tool)
77 
78   @tool = tool
79 end

Public Instance methods

call(mime_type)
[show source]
   # File lib/shrine/plugins/infer_extension.rb
81 def call(mime_type)
82   return nil if mime_type.nil?
83 
84   extension = send(:"infer_with_#{@tool}", mime_type)
85   extension = ".#{extension}" unless extension.nil? || extension.start_with?(".")
86   extension
87 end