class HexaPDF::Utils::ObjectHash

Parent
Included Modules

There are some structures in a PDF file, for example cross reference tables, that index data based on object and generation numbers. However, there is a restriction that in such structures the object numbers must be unique, e.g. there may not be entries for [1, 0] and [1, 1] at the same time.

This class can be used for storing/retrieving data for such structures.

Attributes

max_oid[R]

The biggest object number that is stored in the object hash or zero if no objects are stored.

Public Class Methods

new()

Creates a new object hash.

Public Instance Methods

objhash[oid] → data or nil
objhash[oid, gen] → data or nil

Returns the data for the given object number, or for the given object and generation numbers.

If there is no such data, nil is returned.

objhash[oid, gen] = data

Sets the data for the given object and generation numbers.

If there is already an entry for the given object number (even if the generation number is different), this entry will be removed.

delete(oid)

Deletes the entry for the given object number.

each {|oid, gen, data| block } → objhash
each → Enumerator

Calls the given block once for every entry, passing an array consisting of the object and generation number and the associated data as arguments.

entry?(oid) → true or false
entry?(oid, gen) → true or false

Returns true if there is an entry for the given object number, or for the given object and generation numbers.

gen_for_oid(oid) → Integer or nil

Returns the generation number that is stored along the given object number, or nil if the object number is not used.

oids()

Returns all used object numbers as an array.