Class: PDF::Core::ObjectStore Private
- Inherits:
-
Object
- Object
- PDF::Core::ObjectStore
- Includes:
- Enumerable
- Defined in:
- lib/pdf/core/object_store.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.
PDF object repository
Instance Attribute Summary collapse
-
#min_version ⇒ Float
readonly
private
Minimum PDF version.
Instance Method Summary collapse
-
#[](id) ⇒ Reference
private
Get object reference by its identifier.
-
#each {|ref| ... } ⇒ void
private
Iterate over document object references.
-
#info ⇒ Reference
private
Document info dict reference.
-
#initialize(opts = {}) ⇒ ObjectStore
constructor
private
A new instance of ObjectStore.
-
#object_id_for_page(page) ⇒ Integer
private
Get page reference identifier by page number.Pages are indexed starting at 1 (not 0).
-
#page_count ⇒ Integer
private
Number of pages in the document.
-
#pages ⇒ Reference
private
Document pages reference.
-
#push(reference) ⇒ reference
#push(id, data) ⇒ Reference
(also: #<<)
private
Adds the given reference to the store and returns the reference object.
-
#ref(data) ⇒ Reference
private
Wrap an object into a reference.
-
#root ⇒ Reference
private
Document root dict reference.
-
#size ⇒ Integer
(also: #length)
private
Number of object references in the document.
Constructor Details
#initialize(opts = {}) ⇒ ObjectStore
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 ObjectStore.
Source Code
19 | def initialize(opts = {}) |
20 | @objects = {} |
21 | @identifiers = [] |
22 | |
23 | @info ||= ref(opts[:info] || {}).identifier |
24 | @root ||= ref(Type: :Catalog).identifier |
25 | if opts[:print_scaling] == :none |
26 | root.data[:ViewerPreferences] = { PrintScaling: :None } |
27 | end
|
28 | if pages.nil? |
29 | root.data[:Pages] = ref(Type: :Pages, Count: 0, Kids: []) |
30 | end
|
31 | end
|
Instance Attribute Details
#min_version ⇒ Float (readonly)
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.
Minimum PDF version
Source Code
13 | def min_version |
14 | @min_version
|
15 | end
|
Instance Method Details
#[](id) ⇒ Reference
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.
Get object reference by its identifier.
Source Code
111 | def [](id) |
112 | @objects[id] |
113 | end
|
#each {|ref| ... } ⇒ void
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.
This method returns an undefined value.
Iterate over document object references.
Source Code
101 | def each |
102 | @identifiers.each do |id| |
103 | yield(@objects[id]) |
104 | end
|
105 | end
|
#info ⇒ Reference
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.
Document info dict reference
Source Code
45 | def info |
46 | @objects[@info] |
47 | end
|
#object_id_for_page(page) ⇒ Integer
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.
Get page reference identifier by page number.Pages are indexed starting at 1 (not 0).
Source Code
137 | def object_id_for_page(page) |
138 | page -= 1 if page.positive? |
139 | flat_page_ids = get_page_objects(pages).flatten |
140 | flat_page_ids[page] |
141 | end
|
#page_count ⇒ Integer
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.
Number of pages in the document
Source Code
66 | def page_count |
67 | pages.data[:Count] |
68 | end
|
#pages ⇒ Reference
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.
Document pages reference
Source Code
59 | def pages |
60 | root.data[:Pages] |
61 | end
|
#push(reference) ⇒ reference #push(id, data) ⇒ Reference Also known as: <<
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.
Adds the given reference to the store and returns the reference object. If the object provided is not a PDF::Core::Reference, one is created from the arguments provided.
Source Code
82 | def push(*args) |
83 | reference = |
84 | if args.first.is_a?(PDF::Core::Reference) |
85 | args.first |
86 | else
|
87 | PDF::Core::Reference.new(*args) |
88 | end
|
89 | |
90 | @objects[reference.identifier] = reference |
91 | @identifiers << reference.identifier |
92 | reference
|
93 | end
|
#ref(data) ⇒ Reference
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.
Wrap an object into a reference.
Source Code
38 | def ref(data) |
39 | push(size + 1, data) |
40 | end
|
#root ⇒ Reference
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.
Document root dict reference
Source Code
52 | def root |
53 | @objects[@root] |
54 | end
|
#size ⇒ Integer Also known as: length
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.
Number of object references in the document.
Source Code
118 | def size |
119 | @identifiers.size |
120 | end
|