Class Origami::ObjectStream
In: sources/parser/stream.rb
Parent: Stream

Class representing a Stream containing other Objects.

Methods

<<   delete   each   extract   extract_by_index   include?   index   new   objects  

Included Modules

Enumerable

Public Class methods

Creates a new Object Stream.

dictionary:A hash of attributes to set to the Stream.
rawdata:The Stream data.

[Source]

     # File sources/parser/stream.rb, line 357
357:     def initialize(rawdata = "", dictionary = {})
358:     
359:       @objects = nil
360:      
361:       super(rawdata, dictionary)
362:     end

Public Instance methods

TODO Adds a new Object to this Stream.

object:The Object to append.

[Source]

     # File sources/parser/stream.rb, line 396
396:     def <<(object)
397:       
398:       unless object.generation == 0
399:         raise InvalidObject, "Cannot store an object with generation > 0 in an ObjectStream"
400:       end
401: 
402:       if object.is_a?(Stream)
403:         raise InvalidObject, "Cannot store a Stream in an ObjectStream"
404:       end
405: 
406:       load! if @objects.nil?
407:       
408:       object.no, object.generation = @pdf.alloc_new_object_number if object.no == 0
409:       
410:       object.set_indirect(true) # object is indirect
411:       object.parent = self      # set this stream as the parent
412:       object.set_pdf(@pdf)      # indirect objects need pdf information
413:       @objects[object.no] = object
414:      
415:       Reference.new(object.no, 0)
416:     end

Deletes Object no.

[Source]

     # File sources/parser/stream.rb, line 421
421:     def delete(no)
422:       load! if @objects.nil?
423: 
424:       @objects.delete(no)
425:     end

Iterates over each object in the stream.

[Source]

     # File sources/parser/stream.rb, line 474
474:     def each(&b)
475:       load! if @objects.nil? 
476:       
477:       @objects.values.each(&b)
478:     end

Returns a given decompressed object contained in the Stream.

no:The Object number.

[Source]

     # File sources/parser/stream.rb, line 445
445:     def extract(no)
446:       load! if @objects.nil?
447:     
448:       @objects[no]
449:     end

Returns a given decompressed object by index.

index:The Object index in the ObjectStream.

[Source]

     # File sources/parser/stream.rb, line 455
455:     def extract_by_index(index)
456:       load! if @objects.nil?
457: 
458:       @objects.to_a.sort[index]
459:     end

Returns whether a specific object is contained in this stream.

no:The Object number.

[Source]

     # File sources/parser/stream.rb, line 465
465:     def include?(no)
466:       load! if @objects.nil?
467:     
468:       @objects.include?(no)
469:     end

Returns the index of Object no.

[Source]

     # File sources/parser/stream.rb, line 430
430:     def index(no)
431:       ind = 0
432:       @objects.to_a.sort.each { |num, obj|
433:         return ind if num == no
434: 
435:         ind = ind + 1
436:       }
437: 
438:       nil
439:     end

Returns the array of inner objects.

[Source]

     # File sources/parser/stream.rb, line 483
483:     def objects
484:       load! if @objects.nil?
485:     
486:       @objects.values
487:     end

[Validate]