Class: DooDah::ZipSizeCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/doo_dah/zip_size_calculator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeZipSizeCalculator

Returns a new instance of ZipSizeCalculator.



7
8
9
10
# File 'lib/doo_dah/zip_size_calculator.rb', line 7

def initialize
  @overhead = CentralDirectoryHeader.end_of_central_directory_size
  @size = @overhead
end

Instance Attribute Details

#overheadObject

Returns the value of attribute overhead.



5
6
7
# File 'lib/doo_dah/zip_size_calculator.rb', line 5

def overhead
  @overhead
end

#sizeObject

Returns the value of attribute size.



5
6
7
# File 'lib/doo_dah/zip_size_calculator.rb', line 5

def size
  @size
end

Instance Method Details

#add_file(name, size = 0, crc = 0) ⇒ Object



12
13
14
15
16
# File 'lib/doo_dah/zip_size_calculator.rb', line 12

def add_file(name, size=0, crc=0)
  new_overhead = ZipEntry.overhead(name, size, crc) 
  @overhead += new_overhead
  @size += (size + new_overhead)
end