Class: ContentExtractorFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/content_extractors/content_extractor_factory.rb

Class Method Summary collapse

Class Method Details

.for(file) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/content_extractors/content_extractor_factory.rb', line 9

def self.for(file)
  type = determine_file_type(file)

  case type
  when :pdf
    PdfContentExtractor.new(file)
  when :docx
    DocxContentExtractor.new(file)
  when :txt
    TxtContentExtractor.new(file)
  when :html
    HtmlContentExtractor.new(file)
  else
    raise "Unsupported file type: #{type}"
  end
end