Module: SimpleTextExtract

Defined in:
lib/simple_text_extract.rb,
lib/simple_text_extract/version.rb

Defined Under Namespace

Classes: Error, Extract

Constant Summary collapse

SUPPORTED_FILETYPES =
["xls", "xlsx", "doc", "docx", "txt", "pdf", "csv", "zip"].freeze
VERSION =
"3.0.8"

Class Method Summary collapse

Class Method Details

.extract(filename: nil, raw: nil, filepath: nil, tempfile: nil) ⇒ Object



11
12
13
# File 'lib/simple_text_extract.rb', line 11

def self.extract(filename: nil, raw: nil, filepath: nil, tempfile: nil)
  Extract.new(filename:, raw:, filepath:, tempfile:).to_s
end

.missing_dependency?(command) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/simple_text_extract.rb', line 19

def self.missing_dependency?(command)
  dependency = `sh -c 'command -v #{command}'`
  dependency.nil? || dependency.empty?
end

.supports?(filename: nil) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/simple_text_extract.rb', line 15

def self.supports?(filename: nil)
  SUPPORTED_FILETYPES.include?(filename.to_s.split(".").last)
end