class HexaPDF::Type::ObjectStream::Data
Holds all necessary information to load objects for an object stream.
Public Class Methods
new(stream_data, oids, offsets)
click to toggle source
Initializes the data object with the needed values.
# File lib/hexapdf/type/object_stream.rb, line 79 def initialize(stream_data, oids, offsets) @tokenizer = Tokenizer.new(StringIO.new(stream_data)) @offsets = offsets @oids = oids end
Public Instance Methods
object_by_index(index)
click to toggle source
Returns the object specified by the given index together with its object number.
Objects are not pre-loaded, so every time this method is invoked the associated stream data is parsed and a new object returned.
# File lib/hexapdf/type/object_stream.rb, line 89 def object_by_index(index) if index >= @offsets.size || index < 0 raise ArgumentError, "Invalid index into object stream given" end @tokenizer.pos = @offsets[index] [@tokenizer.next_object, @oids[index]] end