Sha256: fdd3cc6fd10f22542845b7c7ad64a5a4e80b0bdc91531859d4b5793d4c2c3ae3

Contents?: true

Size: 1014 Bytes

Versions: 2

Compression:

Stored size: 1014 Bytes

Contents

# frozen_string_literal: true

require "simple_text_extract/format_extractor/base"
require "simple_text_extract/format_extractor/plain_text"
require "simple_text_extract/format_extractor/pdf"
require "simple_text_extract/format_extractor/xls_x"
require "simple_text_extract/format_extractor/xls"
require "simple_text_extract/format_extractor/doc_x"
require "simple_text_extract/format_extractor/doc"

module SimpleTextExtract
  class FormatExtractorFactory
    def self.call(file) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
      case file.path
      when /.txt$/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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_text_extract-1.0.1 lib/simple_text_extract/format_extractor_factory.rb
simple_text_extract-0.3.0 lib/simple_text_extract/format_extractor_factory.rb