Class representing a Stream containing other Objects.
Adds a new Object to this Stream.
object |
The Object to append. |
# File lib/origami/stream.rb, line 493 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
Deletes Object no.
# File lib/origami/stream.rb, line 518 def delete(no) load! if @objects.nil? @objects.delete(no) end
Iterates over each object in the stream.
# File lib/origami/stream.rb, line 571 def each(&b) load! if @objects.nil? @objects.values.each(&b) end
Returns a given decompressed object by index.
index |
The Object index in the ObjectStream. |
# File lib/origami/stream.rb, line 552 def extract_by_index(index) load! if @objects.nil? @objects.to_a.sort[index] end
Returns whether a specific object is contained in this stream.
no |
The Object number. |
# File lib/origami/stream.rb, line 562 def include?(no) load! if @objects.nil? @objects.include?(no) end
Returns the index of Object no.
# File lib/origami/stream.rb, line 527 def index(no) ind = 0 @objects.to_a.sort.each { |num, obj| return ind if num == no ind = ind + 1 } nil end
Generated with the Darkfish Rdoc Generator 2.