Sha256: f2d85fa755f72247b67abe2130397995028addeab5bd7ee98139888c5e246023
Contents?: true
Size: 721 Bytes
Versions: 5
Compression:
Stored size: 721 Bytes
Contents
module ConvertApi class FormatDetector ANY_FORMAT = 'any' def initialize(resource, to_format) @resource = resource @to_format = to_format end def run return ANY_FORMAT if archive? return @resource.file_ext.downcase if @resource.is_a?(UploadIO) format_from_path || raise(FormatError, 'Unable to detect format') end private def archive? @to_format.to_s.downcase == 'zip' end def format_from_path extension = File.extname(path).downcase extension[1..-1] end def path case @resource when String URI(@resource).path when File @resource.path else '' end end end end
Version data entries
5 entries across 5 versions & 1 rubygems