Class: ConvertApi::FormatDetector
- Inherits:
-
Object
- Object
- ConvertApi::FormatDetector
- Defined in:
- lib/convert_api/format_detector.rb
Constant Summary collapse
- DEFAULT_URL_FORMAT =
'url'
Instance Method Summary collapse
-
#initialize(resource) ⇒ FormatDetector
constructor
A new instance of FormatDetector.
- #run ⇒ Object
Constructor Details
#initialize(resource) ⇒ FormatDetector
5 6 7 |
# File 'lib/convert_api/format_detector.rb', line 5 def initialize(resource) @resource = resource end |
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/convert_api/format_detector.rb', line 9 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 |