Sha256: fad11abbc293c0525cbc1705f65980bea4a30cb0356340dd0696bda54dc78624
Contents?: true
Size: 629 Bytes
Versions: 1
Compression:
Stored size: 629 Bytes
Contents
module ConvertApi class FormatDetector DEFAULT_URL_FORMAT = 'url' def initialize(resource) @resource = resource end def run extension = File.extname(path).downcase return DEFAULT_URL_FORMAT if extension.empty? && @resource =~ URI_REGEXP format = extension[1..-1] raise(FormatError, 'Unable to detect format') if format.nil? format end private def path case @resource when String URI(@resource).path when File @resource.path when UploadIO @resource.filename else '' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
convert_api-1.0.0 | lib/convert_api/format_detector.rb |