Class: SimpleTextExtract::FormatExtractor::ZipExtract

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_text_extract/format_extractor/zip_extract.rb

Instance Attribute Summary

Attributes inherited from Base

#file

Instance Method Summary collapse

Methods inherited from Base

#initialize, #missing_dependency?

Constructor Details

This class inherits a constructor from SimpleTextExtract::FormatExtractor::Base

Instance Method Details

#extractObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simple_text_extract/format_extractor/zip_extract.rb', line 6

def extract
  require "zip"

  result = []
  Zip::File.open(file) do |zip_file|
    zip_file.each do |entry|
      result << entry.name
      result << SimpleTextExtract.extract(
        raw: entry.get_input_stream.read,
        filename: entry.name
      )
    end
  end

  result.join(" ")
end