Included Modules

Class/Module Index [+]

Quicksearch

Origami::ObjectStream

Class representing a Stream containing other Objects.

Public Class Methods

new(rawdata = "", dictionary = {}) click to toggle source

Creates a new Object Stream.

dictionary

A hash of attributes to set to the Stream.

rawdata

The Stream data.

# 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 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
Also aliased as: insert
delete(no) click to toggle source

Deletes Object no.

# File lib/origami/stream.rb, line 518
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 571
def each(&b)
  load! if @objects.nil? 
  
  @objects.values.each(&b)
end
extract(no) click to toggle source

Returns a given decompressed object contained in the Stream.

no

The Object number.

# File lib/origami/stream.rb, line 542
def extract(no)
  load! if @objects.nil?

  @objects[no]
end
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 552
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 562
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 527
def index(no)
  ind = 0
  @objects.to_a.sort.each { |num, obj|
    return ind if num == no

    ind = ind + 1
  }

  nil
end
insert(object) click to toggle source
Alias for: <<
objects() click to toggle source

Returns the array of inner objects.

# File lib/origami/stream.rb, line 580
def objects
  load! if @objects.nil?

  @objects.values
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.