Class Origami::XRefStream
In: sources/parser/xreftable.rb
Parent: Stream

Class representing a XRef Stream.

Methods

<<   each   find   new  

Included Modules

Enumerable Configurable

Constants

XREF_FREE = 0
XREF_USED = 1
XREF_COMPRESSED = 2
W = [ 1, 2, 2 ] unless has_field?(:W)
Size = @xrefs.length + 1

Attributes

xrefs  [R] 

Public Class methods

[Source]

     # File sources/parser/xreftable.rb, line 337
337:     def initialize(data = "", dictionary = {})
338:       super(data, dictionary)
339: 
340:       @xrefs = nil
341:     end

Public Instance methods

Adds an XRef to this Stream.

[Source]

     # File sources/parser/xreftable.rb, line 357
357:     def <<(xref)
358:       load! if @xrefs.nil?
359: 
360:       @xrefs << xref  
361:     end

Iterates over each XRef present in the stream.

[Source]

     # File sources/parser/xreftable.rb, line 366
366:     def each(&b)
367:       load! if @xrefs.nil?
368: 
369:       @xrefs.each(&b)
370:     end

Returns an XRef matching this object number.

[Source]

     # File sources/parser/xreftable.rb, line 375
375:     def find(no)
376:       load! if @xrefs.nil?
377: 
378:       ranges = self.Index || [ 0, @xrefs.length ]
379: 
380:       index = 0
381:       (ranges.size / 2).times do |i|
382:         brange = ranges[i*2].to_i
383:         size = ranges[i*2+1].to_i
384:         return @xrefs[index + no - brange] if Range.new(brange, brange + size) === no
385: 
386:         index += size
387:       end
388: 
389:       nil
390:     end

[Validate]