Class: Omnizip::Formats::Ole::AllocationTable::Big
- Inherits:
-
AllocationTable
- Object
- AllocationTable
- Omnizip::Formats::Ole::AllocationTable::Big
- Defined in:
- lib/omnizip/formats/ole/allocation_table.rb
Overview
Big allocation table (BBAT)
Manages large blocks (typically 512 bytes) for files >= 4096 bytes.
Instance Method Summary collapse
-
#blocks_to_ranges(blocks, size = nil) ⇒ Array<Array<Integer, Integer>>
Big blocks are -1 based to avoid clashing with header.
-
#initialize(ole) ⇒ Big
constructor
A new instance of Big.
Constructor Details
#initialize(ole) ⇒ Big
Returns a new instance of Big.
229 230 231 232 233 |
# File 'lib/omnizip/formats/ole/allocation_table.rb', line 229 def initialize(ole) super @block_size = 1 << @ole.header.b_shift @io = @ole.io end |
Instance Method Details
#blocks_to_ranges(blocks, size = nil) ⇒ Array<Array<Integer, Integer>>
Big blocks are -1 based to avoid clashing with header
240 241 242 243 244 245 246 247 |
# File 'lib/omnizip/formats/ole/allocation_table.rb', line 240 def blocks_to_ranges(blocks, size = nil) return [] if blocks.empty? blocks = blocks[0, (size.to_f / block_size).ceil] if size ranges = blocks.map { |i| [block_size * (i + 1), block_size] } ranges.last[1] -= ((ranges.length * block_size) - size) if ranges.last && size ranges end |