Class: PDF::Writer::Object::Destination

Inherits:
PDF::Writer::Object show all
Defined in:
lib/pdf/writer/object/destination.rb

Overview

Destination object, used to specify the location for the user to jump to; presently, only on opening.

Instance Attribute Summary collapse

Attributes inherited from PDF::Writer::Object

#oid

Instance Method Summary collapse

Constructor Details

#initialize(parent, page, type, *params) ⇒ Destination


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pdf/writer/object/destination.rb', line 14

def initialize(parent, page, type, *params)
  super(parent)

  case type
  when "FitR"
    raise TypeError if params.size < 4
    @string = "/#{type} #{params[0..3].join(' ')}"
  when "XYZ"
    params = (params + [ "null" ] * 4).first(4)
    @string = "/#{type} #{params[0..2].join(' ')}"
  when "FitH", "FitV", "FitBH", "FitBV"
    raise TypeError if params.empty?
    @string = "/#{type} #{params[0]}"
  when "Fit", "FitB"
    @string = "/#{type}"
  end

  @page = page
end

Instance Attribute Details

#pageObject

Returns the value of attribute page


35
36
37
# File 'lib/pdf/writer/object/destination.rb', line 35

def page
  @page
end

#stringObject

Returns the value of attribute string


34
35
36
# File 'lib/pdf/writer/object/destination.rb', line 34

def string
  @string
end

Instance Method Details

#to_sObject


37
38
39
# File 'lib/pdf/writer/object/destination.rb', line 37

def to_s
  "\n#{@oid} 0 obj\n[#{@page.oid} 0 R #{@string}]\nendobj\n"
end