Class: Suvii::Extract::Zip

Inherits:
Suvii::Extract show all
Defined in:
lib/suvii/extract/zip.rb

Overview

Since:

  • 0.1.0

Constant Summary

Constants inherited from Suvii::Extract

TARGZ_RE, UnknownFormatError, ZIP_RE

Instance Attribute Summary

Attributes inherited from Suvii::Extract

#source, #strip_components

Instance Method Summary collapse

Methods inherited from Suvii::Extract

class_for, #initialize

Constructor Details

This class inherits a constructor from Suvii::Extract

Instance Method Details

#extract_to(destination) ⇒ String

Performs archive extraction.

Parameters:

  • destination (String)

    directory where the archive should be extracted.

Returns:

  • (String)

    destination.

Since:

  • 0.1.0



7
8
9
10
11
12
13
14
15
16
# File 'lib/suvii/extract/zip.rb', line 7

def extract_to(destination)
  ::Zip::File.open(source) do |zip_file|
    zip_file.each do |entry|
      path = path_with_stripped_components(entry.name)
      destination_file = File.join(destination, path)
      entry.extract(destination_file)
    end
  end
  destination
end