Class: Omnizip::Algorithms::LZMA2::ChunkManager::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/algorithms/lzma2/chunk_manager.rb

Overview

Chunk data model

Represents a single chunk of data with its metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Chunk

Initialize a chunk

Parameters:

  • data (String)

    Uncompressed chunk data



56
57
58
59
60
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 56

def initialize(data)
  @data = data
  @compressed_data = nil
  @is_compressed = false
end

Instance Attribute Details

#compressed_dataObject

Returns the value of attribute compressed_data.



51
52
53
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 51

def compressed_data
  @compressed_data
end

#dataObject (readonly)

Returns the value of attribute data.



51
52
53
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 51

def data
  @data
end

#is_compressedObject (readonly)

Returns the value of attribute is_compressed.



51
52
53
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 51

def is_compressed
  @is_compressed
end

Instance Method Details

#output_dataString

Get the data to write (compressed or uncompressed)

Returns:

  • (String)

    Data to write



74
75
76
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 74

def output_data
  @is_compressed ? @compressed_data : @data
end

#output_sizeInteger

Get size of output data

Returns:

  • (Integer)

    Size in bytes



81
82
83
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 81

def output_size
  output_data.bytesize
end

#uncompressed_sizeInteger

Get uncompressed size

Returns:

  • (Integer)

    Size in bytes



88
89
90
# File 'lib/omnizip/algorithms/lzma2/chunk_manager.rb', line 88

def uncompressed_size
  @data.bytesize
end