Class: SimpleTextExtract::FormatExtractorFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_text_extract/format_extractor_factory.rb

Class Method Summary collapse

Class Method Details

.call(file) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/simple_text_extract/format_extractor_factory.rb', line 14

def self.call(file)
  case file.path
  when /.zip$/i
    FormatExtractor::ZipExtract.new(file)
  when /(.txt$|.csv$)/i
    FormatExtractor::PlainText.new(file)
  when /.pdf$/i
    FormatExtractor::PDF.new(file)
  when /.docx$/i
    FormatExtractor::DocX.new(file)
  when /.doc$/i
    FormatExtractor::Doc.new(file)
  when /.xlsx$/i
    FormatExtractor::XlsX.new(file)
  when /.xls$/i
    FormatExtractor::Xls.new(file)
  else
    FormatExtractor::Base.new(file)
  end
end