Class: Archive

Inherits:
Struct
  • Object
show all
Defined in:
lib/archivegem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#input_directoryObject

Returns the value of attribute input_directory

Returns:

  • (Object)

    the current value of input_directory



3
4
5
# File 'lib/archivegem.rb', line 3

def input_directory
  @input_directory
end

#output_fileObject

Returns the value of attribute output_file

Returns:

  • (Object)

    the current value of output_file



3
4
5
# File 'lib/archivegem.rb', line 3

def output_file
  @output_file
end

#skipObject

Returns the value of attribute skip

Returns:

  • (Object)

    the current value of skip



3
4
5
# File 'lib/archivegem.rb', line 3

def skip
  @skip
end

Instance Method Details

#zipObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/archivegem.rb', line 4

def zip
    entries = Dir.entries(input_directory)
    entries.delete('.')
    entries.delete('..')

    File.delete(output_file) if File.exist?(output_file)

    io = Zip::File.open(output_file, Zip::File::CREATE)

    write_zip_entries(entries, '', io)
    io.close()
end