Parent

Included Modules

Class/Module Index [+]

Quicksearch

Origami::Array

Class representing an Array Object. Arrays contain a set of Object.

Attributes

names_cache[R]
strings_cache[R]
xref_cache[R]

Public Class Methods

native_type() click to toggle source
# File lib/origami/array.rb, line 171
def self.native_type ; Origami::Array end
new(data = []) click to toggle source

Creates a new PDF Array Object.

data

An array of objects.

# File lib/origami/array.rb, line 49
def initialize(data = [])
  raise TypeError, "Expected type Array, received #{data.class}." unless data.is_a?(::Array)
  super()

  @strings_cache = []
  @names_cache = []
  @xref_cache = {}

  i = 0
  while i < data.size
    case val = data[i].to_o
      when String then @strings_cache.push(val)
      when Name then @names_cache.push(val)
      when Reference then 
        (@xref_cache[val] ||= []).push(self)
      when Dictionary,Array then 
        @strings_cache.concat(val.strings_cache)
        @names_cache.concat(val.names_cache)
        @xref_cache.update(val.xref_cache) do |ref, cache1, cache2|
          cache1.concat(cache2)  
        end

        val.strings_cache.clear
        val.names_cache.clear
        val.xref_cache.clear
    end

    self[i] = val
    i = i + 1
  end
  
end

Public Instance Methods

+(other) click to toggle source
# File lib/origami/array.rb, line 132
def +(other)
  
  a = Origami::Array.new(self.to_a + other.to_a,  is_indirect?)
  a.no, a.generation = @no, @generation
  
  return a
end
<<(item) click to toggle source
# File lib/origami/array.rb, line 140
def <<(item)
  obj = item.to_o
  obj.parent = self unless obj.is_indirect?

  super(obj)
end
[]=(key,val) click to toggle source
# File lib/origami/array.rb, line 147
def []=(key,val)
  key, val = key.to_o, val.to_o
  super(key.to_o,val.to_o)
 
  val.parent = self unless val.is_indirect? or val.parent.equal?(self)

  val
end
copy() click to toggle source
# File lib/origami/array.rb, line 158
def copy
  copy = self.class.new
  self.each do |obj|
    copy << obj.copy
  end

  copy.parent = @parent
  copy.no, copy.generation = @no, @generation
  copy.set_indirect(true) if is_indirect?
  copy.set_pdf(@pdf) if is_indirect?
  copy
end
pre_build() click to toggle source
# File lib/origami/array.rb, line 82
def pre_build
  self.map!{|obj| obj.to_o}
  
  super
end
to_a() click to toggle source

Converts self into a Ruby array.

# File lib/origami/array.rb, line 116
def to_a
  super.map { |item|
    item.is_a?(Origami::Object) ? item.value : item
  }
end
Also aliased as: value
to_obfuscated_str() click to toggle source
# File lib/origami/obfuscation.rb, line 136
def to_obfuscated_str
  content = TOKENS.first + Obfuscator.junk_spaces
  self.each { |entry|
    content << entry.to_o.to_obfuscated_str + Obfuscator.junk_spaces
  }

  content << TOKENS.last

  super(content)
end
value() click to toggle source
Alias for: to_a

[Validate]

Generated with the Darkfish Rdoc Generator 2.