Class: Pdfrb::XrefSection
- Inherits:
-
Object
- Object
- Pdfrb::XrefSection
- Defined in:
- lib/pdfrb/xref_section.rb
Overview
In-memory cross-reference section (s7.5.4). Maps oid -> Entry where each Entry is one of:
* :in_use — at +offset+ in the file, generation +gen+.
* :free — head of free list (with next-free oid +gen+).
* :compressed — inside ObjStm +obj_stm_oid+ at index +index+.
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #[](oid) ⇒ Object
- #add_compressed(oid, obj_stm_oid, index) ⇒ Object
- #add_free(oid, gen, next_free) ⇒ Object
- #add_in_use(oid, gen, offset) ⇒ Object
- #each_entry(&block) ⇒ Object
-
#initialize(size: 0) ⇒ XrefSection
constructor
A new instance of XrefSection.
- #merge!(other) ⇒ Object
Constructor Details
#initialize(size: 0) ⇒ XrefSection
Returns a new instance of XrefSection.
18 19 20 21 |
# File 'lib/pdfrb/xref_section.rb', line 18 def initialize(size: 0) @entries = {} @size = size end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
16 17 18 |
# File 'lib/pdfrb/xref_section.rb', line 16 def entries @entries end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
16 17 18 |
# File 'lib/pdfrb/xref_section.rb', line 16 def size @size end |
Instance Method Details
#[](oid) ⇒ Object
37 38 39 |
# File 'lib/pdfrb/xref_section.rb', line 37 def [](oid) @entries[oid] end |
#add_compressed(oid, obj_stm_oid, index) ⇒ Object
32 33 34 35 |
# File 'lib/pdfrb/xref_section.rb', line 32 def add_compressed(oid, obj_stm_oid, index) @entries[oid] = Entry.new(type: :compressed, obj_stm_oid: obj_stm_oid, index: index) @size = [@size, oid + 1].max end |
#add_free(oid, gen, next_free) ⇒ Object
28 29 30 |
# File 'lib/pdfrb/xref_section.rb', line 28 def add_free(oid, gen, next_free) @entries[oid] = Entry.new(type: :free, offset: next_free, gen: gen) end |
#add_in_use(oid, gen, offset) ⇒ Object
23 24 25 26 |
# File 'lib/pdfrb/xref_section.rb', line 23 def add_in_use(oid, gen, offset) @entries[oid] = Entry.new(type: :in_use, offset: offset, gen: gen) @size = [@size, oid + 1].max end |
#each_entry(&block) ⇒ Object
41 42 43 |
# File 'lib/pdfrb/xref_section.rb', line 41 def each_entry(&block) @entries.each(&block) end |
#merge!(other) ⇒ Object
45 46 47 48 49 |
# File 'lib/pdfrb/xref_section.rb', line 45 def merge!(other) other.entries.each { |oid, e| @entries[oid] = e unless @entries.key?(oid) } @size = [@size, other.size].max self end |