class Origami::ObjectStream
Class representing a Stream containing other Objects.
Public Class Methods
new(rawdata = "", dictionary = {})
click to toggle source
Calls superclass method
Origami::Stream.new
# File lib/origami/stream.rb, line 456 def initialize(rawdata = "", dictionary = {}) @objects = nil super(rawdata, dictionary) end
Public Instance Methods
<<(object)
click to toggle source
Adds a new Object to this Stream.
- object
-
The Object to append.
# File lib/origami/stream.rb, line 494 def <<(object) unless object.generation == 0 raise InvalidObjectError, "Cannot store an object with generation > 0 in an ObjectStream" end if object.is_a?(Stream) raise InvalidObjectError, "Cannot store a Stream in an ObjectStream" end load! if @objects.nil? object.no, object.generation = @pdf.alloc_new_object_number if object.no == 0 object.set_indirect(true) # object is indirect object.parent = self # set this stream as the parent object.set_pdf(@pdf) # indirect objects need pdf information @objects[object.no] = object Reference.new(object.no, 0) end
Also aliased as: insert
delete(no)
click to toggle source
Deletes Object no.
# File lib/origami/stream.rb, line 519 def delete(no) load! if @objects.nil? @objects.delete(no) end
each(&b)
click to toggle source
Iterates over each object in the stream.
# File lib/origami/stream.rb, line 572 def each(&b) load! if @objects.nil? @objects.values.each(&b) end
extract(no)
click to toggle source
extract_by_index(index)
click to toggle source
Returns a given decompressed object by index.
- index
-
The Object index in the ObjectStream.
# File lib/origami/stream.rb, line 553 def extract_by_index(index) load! if @objects.nil? @objects.to_a.sort[index] end
include?(no)
click to toggle source
Returns whether a specific object is contained in this stream.
- no
-
The Object number.
# File lib/origami/stream.rb, line 563 def include?(no) load! if @objects.nil? @objects.include?(no) end
index(no)
click to toggle source
Returns the index of Object no.
# File lib/origami/stream.rb, line 528 def index(no) ind = 0 @objects.to_a.sort.each { |num, obj| return ind if num == no ind = ind + 1 } nil end
objects()
click to toggle source
Returns the array of inner objects.
# File lib/origami/stream.rb, line 581 def objects load! if @objects.nil? @objects.values end