Class: ConvertApi::FormatDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/convert_api/format_detector.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ FormatDetector

Returns a new instance of FormatDetector.



3
4
5
# File 'lib/convert_api/format_detector.rb', line 3

def initialize(resource)
  @resource = resource
end

Instance Method Details

#runObject

Raises:



7
8
9
10
11
12
13
14
# File 'lib/convert_api/format_detector.rb', line 7

def run
  extension = File.extname(path).downcase
  format = extension[1..-1]

  raise(FormatError, 'Unable to detect format') if format.nil?

  format
end