Class: RPDF::PDFArray

Inherits:
PDFObject show all
Defined in:
lib/rpdf/pdfarray.rb

Overview

Array Object

PDFRef15 p34

Direct Known Subclasses

Rectangle

Instance Attribute Summary collapse

Attributes inherited from PDFObject

#generation_number, #object_number

Instance Method Summary collapse

Methods inherited from PDFObject

#indirect?, #invalidate, #invalidated?, #to_pdf, #to_ref

Constructor Details

#initialize(array, document = nil) ⇒ PDFArray

Returns a new instance of PDFArray.

Raises:

  • (Exception)


11
12
13
14
15
16
17
18
# File 'lib/rpdf/pdfarray.rb', line 11

def initialize(array, document=nil)
  raise Exception.new("PDFArray is not an array") unless array.kind_of?(Array)
  @array = Array.new
  array.each { |object|
    @array << RPDF.topdfobject(object, document)
  }
  super(document)
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



9
10
11
# File 'lib/rpdf/pdfarray.rb', line 9

def array
  @array
end

Instance Method Details

#<<(element) ⇒ Object



20
21
22
# File 'lib/rpdf/pdfarray.rb', line 20

def <<(element)
  @array << RPDF.topdfobject(element)
end

#to_sObject



24
25
26
27
28
29
30
31
# File 'lib/rpdf/pdfarray.rb', line 24

def to_s
  bytes = "[ "
  @array.each { |element|
    bytes << element.to_ref # to_ref -> reference to indirect object
    bytes << " "
  }
  bytes << "]"
end