Class: SimpleTextExtract::TextExtractor

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

Direct Known Subclasses

FileExtractor, TempfileExtractor

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(filename: nil, raw: nil, filepath: nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/simple_text_extract/text_extractor.rb', line 5

def self.call(filename: nil, raw: nil, filepath: nil)
  if !filename.nil? && !raw.nil?
    TempfileExtractor.new(filename: filename.to_s, raw: raw).extract
  elsif !filepath.nil? && File.exist?(filepath)
    FileExtractor.new(filepath: filepath).extract
  end
end

Instance Method Details

#extract ⇒ Object



13
14
15
16
17
18
# File 'lib/simple_text_extract/text_extractor.rb', line 13

def extract
  text = FormatExtractorFactory.call(file).extract
  cleanup

  text
end