module DocRipper

encoding: UTF-8

Constants

VERSION

Public Class Methods

rip(path, options = {}) click to toggle source
# File lib/doc_ripper.rb, line 13
def rip(path, options = {})
  ripper = choose_ripper(path)
  ripper.text unless ripper.nil?
end
rip!(path) click to toggle source
# File lib/doc_ripper.rb, line 18
def rip!(path)
  ripper = choose_ripper(path)
  raise(UnsupportedFileType) if ripper.nil?

  ripper.text || raise(FileNotFound)
end

Private Class Methods

choose_ripper(file_path) click to toggle source
# File lib/doc_ripper.rb, line 27
def choose_ripper(file_path)
  ripper = begin
    case
    when !!(file_path =~ /.docx$/i)
      ripper = Formats::DocxRipper.new(file_path)
    when !!(file_path =~ /.doc$/i)
      ripper = Formats::MsDocRipper.new(file_path)
    when !!(file_path =~ /.pdf$/i)
      ripper = Formats::PdfRipper.new(file_path)
    when !!(file_path =~ /.sketch$/i)
      ripper = Formats::SketchRipper.new(file_path)
    when !!(file_path =~ /.txt$/i)
      ripper = Formats::TextRipper.new(file_path)
    end
  end

  ripper
end