Class: PDF::Core::Reference Private
- Inherits:
-
Object
- Object
- PDF::Core::Reference
- Defined in:
- lib/pdf/core/reference.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 indirect objects
Defined Under Namespace
Classes: CannotAttachStream
Instance Attribute Summary collapse
-
#data ⇒ any
private
Object data.
-
#gen ⇒ Integer
private
Object generation.
-
#identifier ⇒ Integer
private
Object identifier.
-
#offset ⇒ Integer
private
Offset of the serialized object in the document.
-
#stream ⇒ Stream
private
Object stream.
Instance Method Summary collapse
-
#<<(io) ⇒ io
private
Appends data to object stream.
-
#deep_copy(share = []) ⇒ Reference
private
Creates a deep copy of this ref.
-
#initialize(id, data) ⇒ Reference
constructor
private
A new instance of Reference.
-
#object ⇒ String
private
Serialized PDF object.
-
#replace(other_ref) ⇒ void
private
Replaces the data and stream with that of other_ref.
-
#to_s ⇒ String
private
Object reference in PDF format.
Constructor Details
#initialize(id, 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.
Returns a new instance of Reference.
Source Code
42 | def initialize(id, data) |
43 | @identifier = id |
44 | @gen = 0 |
45 | @data = data |
46 | @stream = Stream.new |
47 | end
|
Instance Attribute Details
#data ⇒ any
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.
Object data
Source Code
21 | def data |
22 | @data
|
23 | end
|
#gen ⇒ 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.
Object generation
Source Code
17 | def gen |
18 | @gen
|
19 | end
|
#identifier ⇒ 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.
Object identifier
Source Code
13 | def identifier |
14 | @identifier
|
15 | end
|
#offset ⇒ 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.
Offset of the serialized object in the document
Source Code
25 | def offset |
26 | @offset
|
27 | end
|
#stream ⇒ Stream
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.
Object stream
Source Code
29 | def stream |
30 | @stream
|
31 | end
|
Instance Method Details
#<<(io) ⇒ io
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.
Appends data to object stream
Source Code
69 | def <<(io) |
70 | unless @data.is_a?(::Hash) |
71 | raise CannotAttachStream |
72 | end
|
73 | |
74 | (@stream ||= Stream.new) << io |
75 | end
|
#deep_copy(share = []) ⇒ 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.
Creates a deep copy of this ref.
Source Code
89 | def deep_copy(share = []) |
90 | r = dup |
91 | |
92 | case r.data |
93 | when ::Hash |
94 | # Copy each entry not in +share+.
|
95 | (r.data.keys - share).each do |k| |
96 | r.data[k] = Utils.deep_clone(r.data[k]) |
97 | end
|
98 | when PDF::Core::NameTree::Node |
99 | r.data = r.data.deep_copy |
100 | else
|
101 | r.data = Utils.deep_clone(r.data) |
102 | end
|
103 | |
104 | r.stream = Utils.deep_clone(r.stream) |
105 | r
|
106 | end
|
#object ⇒ String
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.
Serialized PDF object
Source Code
52 | def object |
53 | output = +"#{@identifier} #{gen} obj\n" |
54 | if @stream.empty? |
55 | output << PDF::Core.pdf_object(data) << "\n" |
56 | else
|
57 | output << PDF::Core.pdf_object(data.merge(@stream.data)) << |
58 | "\n" << @stream.object |
59 | end
|
60 | |
61 | output << "endobj\n" |
62 | end
|
#replace(other_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.
Replaces the data and stream with that of other_ref.
Source Code
112 | def replace(other_ref) |
113 | @data = other_ref.data |
114 | @stream = other_ref.stream |
115 | end
|
#to_s ⇒ String
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.
Object reference in PDF format
Source Code
80 | def to_s |
81 | "#{@identifier} #{gen} R" |
82 | end
|