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