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

rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity



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

def self.call(file) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
  case file.path
  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