Class: Omnizip::Formats::SevenZip::Models::Folder

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeFolder

Initialize folder

Parameters:

  • coders (Array<CoderInfo>)

    Array of coders

  • bind_pairs (Array<Array<Integer>>)

    Stream bindings

  • pack_stream_indices (Array<Integer>)

    Pack stream indices



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_pairsObject

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

#codersObject

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_indicesObject

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_crcObject

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_sizesObject

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_codersInteger

Get number of coders in folder

Returns:

  • (Integer)

    Coder count



29
30
31
# File 'lib/omnizip/formats/seven_zip/models/folder.rb', line 29

def num_coders
  @coders.size
end

#num_in_streamsInteger

Get total number of input streams

Returns:

  • (Integer)

    Input stream count



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_streamsInteger

Get total number of output streams

Returns:

  • (Integer)

    Output stream count



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_sizeInteger

Get uncompressed size of folder's final output stream Finds the output stream that is not bound as input

Returns:

  • (Integer)

    Uncompressed size



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