Class: ZipDir::Zipper

Inherits:
Dir
  • Object
show all
Defined in:
lib/zip_dir/zipper.rb

Constant Summary collapse

DEFAULT_FILENAME =
"zipper.zip".freeze

Instance Attribute Summary collapse

Attributes inherited from Dir

#copy_path

Instance Method Summary collapse

Methods inherited from Dir

#generated?

Constructor Details

#initialize(filename = DEFAULT_FILENAME) ⇒ Zipper

Returns a new instance of Zipper.



10
11
12
# File 'lib/zip_dir/zipper.rb', line 10

def initialize(filename=DEFAULT_FILENAME)
  @filename = filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/zip_dir/zipper.rb', line 6

def filename
  @filename
end

Instance Method Details

#cleanupObject



19
20
21
22
# File 'lib/zip_dir/zipper.rb', line 19

def cleanup
  super
  @file = nil
end

#fileObject



24
25
26
27
# File 'lib/zip_dir/zipper.rb', line 24

def file
  return unless generated?
  @file
end

#generate(source_path = nil, root_directory: false) ⇒ Object



14
15
16
17
# File 'lib/zip_dir/zipper.rb', line 14

def generate(source_path=nil, root_directory: false)
  super
  @file = ZipDir::Zip.new(copy_path, filename).file
end