Class: Railsmdb::ZipExtractor Private

Inherits:
Extractor show all
Defined in:
lib/railsmdb/extractor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An extractor subclass for dealing with .zip files.

Instance Attribute Summary

Attributes inherited from Extractor

#archive_path

Instance Method Summary collapse

Methods inherited from Extractor

for, #initialize

Constructor Details

This class inherits a constructor from Railsmdb::Extractor

Instance Method Details

#extract(pattern) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Extractor#extract for documentation.



57
58
59
60
61
62
63
64
65
66
# File 'lib/railsmdb/extractor.rb', line 57

def extract(pattern)
  Zip::File.open(archive_path).each do |entry|
    if entry.name.match?(pattern)
      yield entry.name, entry.get_input_stream.read.force_encoding('BINARY')
      return entry.name
    end
  end

  nil
end