Class: PDF::Core::OutlineItem Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/core/outline_item.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Outline item.

See Also:

  • PDF 1.7 spec, section 8.2.2 Document Outline

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, parent, options) ⇒ OutlineItem

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of OutlineItem.

Parameters:

Options Hash (options):

  • :closed (Boolean)


54
55
56
57
58
59
# File 'lib/pdf/core/outline_item.rb', line 54

def initialize(title, parent, options)
  @closed = options[:closed]
  @title = title
  @parent = parent
  @count = 0
end

Instance Attribute Details

#closedBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Is this item open or closed.

Returns:

  • (Boolean)


48
49
50
# File 'lib/pdf/core/outline_item.rb', line 48

def closed
  @closed
end

#countInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The total number of its open descendants at all lower levels of the outline hierarchy.

Returns:

  • (Integer)


13
14
15
# File 'lib/pdf/core/outline_item.rb', line 13

def count
  @count
end

#destString, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The destination to be displayed when this item is activated.

Returns:

  • (String)
  • (Symbol)
  • (Array)

See Also:



44
45
46
# File 'lib/pdf/core/outline_item.rb', line 44

def dest
  @dest
end

#firstReference<PDF::Core::OutlineItem>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The first of this item’s immediate children in the outline hierarchy.



17
18
19
# File 'lib/pdf/core/outline_item.rb', line 17

def first
  @first
end

#lastReference<PDF::Core::OutlineItem>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The last of this item’s immediate children in the outline hierarchy.



21
22
23
# File 'lib/pdf/core/outline_item.rb', line 21

def last
  @last
end

#nextReference<PDF::Core::OutlineItem>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The next item at this outline level.



25
26
27
# File 'lib/pdf/core/outline_item.rb', line 25

def next
  @next
end

#parentReference<[PDF::Core::OutlineItem, PDF::Core::OutlineRoot]>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The parent of this item in the outline hierarchy.



33
34
35
# File 'lib/pdf/core/outline_item.rb', line 33

def parent
  @parent
end

#prevReference<PDF::Core::OutlineItem>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The previous item at this outline level.



29
30
31
# File 'lib/pdf/core/outline_item.rb', line 29

def prev
  @prev
end

#titleString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The text to be displayed on the screen for this item.

Returns:

  • (String)


37
38
39
# File 'lib/pdf/core/outline_item.rb', line 37

def title
  @title
end

Instance Method Details

#to_hashHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A hash representation of this outline item.

Returns:

  • (Hash)


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pdf/core/outline_item.rb', line 64

def to_hash
  hash = {
    Title: title,
    Parent: parent,
    Count: closed ? -count : count,
  }
  [
    { First: first }, { Last: last }, { Next: defined?(@next) && @next },
    { Prev: prev }, { Dest: dest },
  ].each do |h|
    unless h.values.first.nil?
      hash.merge!(h)
    end
  end
  hash
end