Class: Cabriolet::Models::Folder
- Inherits:
-
Object
- Object
- Cabriolet::Models::Folder
- Defined in:
- lib/cabriolet/models/folder.rb
Overview
Folder represents a compressed data stream within a cabinet
Instance Attribute Summary collapse
-
#comp_type ⇒ Object
Returns the value of attribute comp_type.
-
#data ⇒ Object
Returns the value of attribute data.
-
#merge_next ⇒ Object
Returns the value of attribute merge_next.
-
#merge_prev ⇒ Object
Returns the value of attribute merge_prev.
-
#next_folder ⇒ Object
Returns the value of attribute next_folder.
-
#num_blocks ⇒ Object
Returns the value of attribute num_blocks.
Instance Method Summary collapse
-
#compression_level ⇒ Integer
Get the compression level (for LZX and Quantum).
-
#compression_method ⇒ Integer
Get the compression method.
-
#compression_name ⇒ String
Get human-readable compression name.
-
#data_cab ⇒ Cabinet?
Get the primary data cabinet (for backwards compatibility).
-
#data_cab=(cabinet) ⇒ Object
Set the primary data cabinet (for backwards compatibility).
-
#data_offset ⇒ Integer
Get the primary data offset (for backwards compatibility).
-
#data_offset=(offset) ⇒ Object
Set the primary data offset (for backwards compatibility).
-
#initialize(cabinet = nil, offset = 0) ⇒ Folder
constructor
Initialize a new folder.
-
#needs_next_merge? ⇒ Boolean
Check if this folder needs to be merged with a next folder.
-
#needs_prev_merge? ⇒ Boolean
Check if this folder needs to be merged with a previous folder.
-
#uncompressed? ⇒ Boolean
Check if this folder is uncompressed.
Constructor Details
#initialize(cabinet = nil, offset = 0) ⇒ Folder
Initialize a new folder
16 17 18 19 20 21 22 23 |
# File 'lib/cabriolet/models/folder.rb', line 16 def initialize(cabinet = nil, offset = 0) @comp_type = Constants::COMP_TYPE_NONE @num_blocks = 0 @data = FolderData.new(cabinet, offset) @next_folder = nil @merge_prev = nil @merge_next = nil end |
Instance Attribute Details
#comp_type ⇒ Object
Returns the value of attribute comp_type.
9 10 11 |
# File 'lib/cabriolet/models/folder.rb', line 9 def comp_type @comp_type end |
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/cabriolet/models/folder.rb', line 9 def data @data end |
#merge_next ⇒ Object
Returns the value of attribute merge_next.
9 10 11 |
# File 'lib/cabriolet/models/folder.rb', line 9 def merge_next @merge_next end |
#merge_prev ⇒ Object
Returns the value of attribute merge_prev.
9 10 11 |
# File 'lib/cabriolet/models/folder.rb', line 9 def merge_prev @merge_prev end |
#next_folder ⇒ Object
Returns the value of attribute next_folder.
9 10 11 |
# File 'lib/cabriolet/models/folder.rb', line 9 def next_folder @next_folder end |
#num_blocks ⇒ Object
Returns the value of attribute num_blocks.
9 10 11 |
# File 'lib/cabriolet/models/folder.rb', line 9 def num_blocks @num_blocks end |
Instance Method Details
#compression_level ⇒ Integer
Get the compression level (for LZX and Quantum)
63 64 65 |
# File 'lib/cabriolet/models/folder.rb', line 63 def compression_level (@comp_type >> 8) & 0x1F end |
#compression_method ⇒ Integer
Get the compression method
56 57 58 |
# File 'lib/cabriolet/models/folder.rb', line 56 def compression_method @comp_type & Constants::COMP_TYPE_MASK end |
#compression_name ⇒ String
Get human-readable compression name
70 71 72 73 74 75 76 77 78 |
# File 'lib/cabriolet/models/folder.rb', line 70 def compression_name case compression_method when Constants::COMP_TYPE_NONE then "None" when Constants::COMP_TYPE_MSZIP then "MSZIP" when Constants::COMP_TYPE_QUANTUM then "Quantum" when Constants::COMP_TYPE_LZX then "LZX" else "Unknown" end end |
#data_cab ⇒ Cabinet?
Get the primary data cabinet (for backwards compatibility)
28 29 30 |
# File 'lib/cabriolet/models/folder.rb', line 28 def data_cab @data.cabinet end |
#data_cab=(cabinet) ⇒ Object
Set the primary data cabinet (for backwards compatibility)
35 36 37 |
# File 'lib/cabriolet/models/folder.rb', line 35 def data_cab=(cabinet) @data.cabinet = cabinet end |
#data_offset ⇒ Integer
Get the primary data offset (for backwards compatibility)
42 43 44 |
# File 'lib/cabriolet/models/folder.rb', line 42 def data_offset @data.offset end |
#data_offset=(offset) ⇒ Object
Set the primary data offset (for backwards compatibility)
49 50 51 |
# File 'lib/cabriolet/models/folder.rb', line 49 def data_offset=(offset) @data.offset = offset end |
#needs_next_merge? ⇒ Boolean
Check if this folder needs to be merged with a next folder
97 98 99 |
# File 'lib/cabriolet/models/folder.rb', line 97 def needs_next_merge? !@merge_next.nil? end |
#needs_prev_merge? ⇒ Boolean
Check if this folder needs to be merged with a previous folder
90 91 92 |
# File 'lib/cabriolet/models/folder.rb', line 90 def needs_prev_merge? !@merge_prev.nil? end |
#uncompressed? ⇒ Boolean
Check if this folder is uncompressed
83 84 85 |
# File 'lib/cabriolet/models/folder.rb', line 83 def uncompressed? compression_method == Constants::COMP_TYPE_NONE end |