Class: PDF::Core::OutlineItem

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, parent, options) ⇒ OutlineItem

Returns a new instance of OutlineItem.



8
9
10
11
12
13
# File 'lib/pdf/core/outline_item.rb', line 8

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

Instance Attribute Details

#closedObject

Returns the value of attribute closed.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def closed
  @closed
end

#countObject

Returns the value of attribute count.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def count
  @count
end

#destObject

Returns the value of attribute dest.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def dest
  @dest
end

#firstObject

Returns the value of attribute first.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def first
  @first
end

#lastObject

Returns the value of attribute last.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def last
  @last
end

#nextObject

Returns the value of attribute next.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def next
  @next
end

#parentObject

Returns the value of attribute parent.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def parent
  @parent
end

#prevObject

Returns the value of attribute prev.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def prev
  @prev
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/pdf/core/outline_item.rb', line 6

def title
  @title
end

Instance Method Details

#to_hashObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pdf/core/outline_item.rb', line 15

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