Array
# File lib/origami/array.rb, line 171 def self.native_type ; Origami::Array end
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
# 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
# File lib/origami/array.rb, line 140 def <<(item) obj = item.to_o obj.parent = self unless obj.is_indirect? super(obj) end
# 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
# 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
# File lib/origami/array.rb, line 82 def pre_build self.map!{|obj| obj.to_o} super end
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
Generated with the Darkfish Rdoc Generator 2.