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 345
345:     def initialize(rawdata = "", dictionary = {})
346:     
347:       @objects = nil
348:      
349:       super(rawdata, dictionary)
350:     end

Public Instance methods

TODO Adds a new Object to this Stream.

object:The Object to append.

[Source]

     # File sources/parser/stream.rb, line 384
384:     def <<(object)
385:       
386:       unless object.generation == 0
387:         raise InvalidObject, "Cannot store an object with generation > 0 in an ObjectStream"
388:       end
389: 
390:       if object.is_a?(Stream)
391:         raise InvalidObject, "Cannot store a Stream in an ObjectStream"
392:       end
393: 
394:       load! if @objects.nil?
395:       
396:       object.no, object.generation = @pdf.alloc_new_object_number if object.no == 0
397:       
398:       object.set_indirect(true) # object is indirect
399:       object.parent = self      # set this stream as the parent
400:       object.set_pdf(@pdf)      # indirect objects need pdf information
401:       @objects[object.no] = object
402:      
403:       Reference.new(object.no, 0)
404:     end

Deletes Object no.

[Source]

     # File sources/parser/stream.rb, line 409
409:     def delete(no)
410:       load! if @objects.nil?
411: 
412:       @objects.delete(no)
413:     end

Iterates over each object in the stream.

[Source]

     # File sources/parser/stream.rb, line 462
462:     def each(&b)
463:       load! if @objects.nil? 
464:       
465:       @objects.values.each(&b)
466:     end

Returns a given decompressed object contained in the Stream.

no:The Object number.

[Source]

     # File sources/parser/stream.rb, line 433
433:     def extract(no)
434:       load! if @objects.nil?
435:     
436:       @objects[no]
437:     end

Returns a given decompressed object by index.

index:The Object index in the ObjectStream.

[Source]

     # File sources/parser/stream.rb, line 443
443:     def extract_by_index(index)
444:       load! if @objects.nil?
445: 
446:       @objects.to_a.sort[index]
447:     end

Returns whether a specific object is contained in this stream.

no:The Object number.

[Source]

     # File sources/parser/stream.rb, line 453
453:     def include?(no)
454:       load! if @objects.nil?
455:     
456:       @objects.include?(no)
457:     end

Returns the index of Object no.

[Source]

     # File sources/parser/stream.rb, line 418
418:     def index(no)
419:       ind = 0
420:       @objects.to_a.sort.each { |num, obj|
421:         return ind if num == no
422: 
423:         ind = ind + 1
424:       }
425: 
426:       nil
427:     end

Returns the array of inner objects.

[Source]

     # File sources/parser/stream.rb, line 471
471:     def objects
472:       load! if @objects.nil?
473:     
474:       @objects.values
475:     end

[Validate]