Class: Omnizip::Formats::SevenZip::Models::Folder
- Inherits:
-
Object
- Object
- Omnizip::Formats::SevenZip::Models::Folder
- Defined in:
- lib/omnizip/formats/seven_zip/models/folder.rb
Overview
Represents a folder (compression group) in .7z format Contains coder chain and binding information
Instance Attribute Summary collapse
-
#bind_pairs ⇒ Object
Returns the value of attribute bind_pairs.
-
#coders ⇒ Object
Returns the value of attribute coders.
-
#pack_stream_indices ⇒ Object
Returns the value of attribute pack_stream_indices.
-
#unpack_crc ⇒ Object
Returns the value of attribute unpack_crc.
-
#unpack_sizes ⇒ Object
Returns the value of attribute unpack_sizes.
Instance Method Summary collapse
-
#initialize ⇒ Folder
constructor
Initialize folder.
-
#num_coders ⇒ Integer
Get number of coders in folder.
-
#num_in_streams ⇒ Integer
Get total number of input streams.
-
#num_out_streams ⇒ Integer
Get total number of output streams.
-
#uncompressed_size ⇒ Integer
Get uncompressed size of folder's final output stream Finds the output stream that is not bound as input.
Constructor Details
#initialize ⇒ Folder
Initialize folder
18 19 20 21 22 23 24 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 18 def initialize @coders = [] @bind_pairs = [] @pack_stream_indices = [] @unpack_sizes = [] @unpack_crc = nil end |
Instance Attribute Details
#bind_pairs ⇒ Object
Returns the value of attribute bind_pairs.
10 11 12 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 10 def bind_pairs @bind_pairs end |
#coders ⇒ Object
Returns the value of attribute coders.
10 11 12 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 10 def coders @coders end |
#pack_stream_indices ⇒ Object
Returns the value of attribute pack_stream_indices.
10 11 12 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 10 def pack_stream_indices @pack_stream_indices end |
#unpack_crc ⇒ Object
Returns the value of attribute unpack_crc.
10 11 12 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 10 def unpack_crc @unpack_crc end |
#unpack_sizes ⇒ Object
Returns the value of attribute unpack_sizes.
10 11 12 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 10 def unpack_sizes @unpack_sizes end |
Instance Method Details
#num_coders ⇒ Integer
Get number of coders in folder
29 30 31 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 29 def num_coders @coders.size end |
#num_in_streams ⇒ Integer
Get total number of input streams
43 44 45 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 43 def num_in_streams @coders.sum(&:num_in_streams) end |
#num_out_streams ⇒ Integer
Get total number of output streams
36 37 38 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 36 def num_out_streams @coders.sum(&:num_out_streams) end |
#uncompressed_size ⇒ Integer
Get uncompressed size of folder's final output stream Finds the output stream that is not bound as input
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 51 def uncompressed_size # Find which output stream is the final one (not bound as input) n = num_out_streams - 1 while n >= 0 # Check if this output is bound as input bound = @bind_pairs.any? { |pair| pair[1] == n } return @unpack_sizes[n] || 0 unless bound n -= 1 end 0 end |