Method: Datasets::ZipExtractor#extract_file

Defined in:
lib/datasets/zip-extractor.rb

#extract_file(file_path) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/datasets/zip-extractor.rb', line 22

def extract_file(file_path)
  Zip::File.open(@path) do |zip_file|
    zip_file.each do |entry|
      next unless entry.file?
      next unless entry.name == file_path

      entry.get_input_stream do |input|
        return yield(input)
      end
    end
  end
  nil
end