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.
42 43 44 45 46 47 |
# File 'lib/pdf/core/reference.rb', line 42 def initialize(id, data) @identifier = id @gen = 0 @data = data @stream = Stream.new 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
21 22 23 |
# File 'lib/pdf/core/reference.rb', line 21 def data @data 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
17 18 19 |
# File 'lib/pdf/core/reference.rb', line 17 def gen @gen 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
13 14 15 |
# File 'lib/pdf/core/reference.rb', line 13 def identifier @identifier 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
25 26 27 |
# File 'lib/pdf/core/reference.rb', line 25 def offset @offset 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
29 30 31 |
# File 'lib/pdf/core/reference.rb', line 29 def stream @stream 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
69 70 71 72 73 74 75 |
# File 'lib/pdf/core/reference.rb', line 69 def <<(io) unless @data.is_a?(::Hash) raise CannotAttachStream end (@stream ||= Stream.new) << io 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.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/pdf/core/reference.rb', line 89 def deep_copy(share = []) r = dup case r.data when ::Hash # Copy each entry not in +share+. (r.data.keys - share).each do |k| r.data[k] = Utils.deep_clone(r.data[k]) end when PDF::Core::NameTree::Node r.data = r.data.deep_copy else r.data = Utils.deep_clone(r.data) end r.stream = Utils.deep_clone(r.stream) r 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
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pdf/core/reference.rb', line 52 def object output = +"#{@identifier} #{gen} obj\n" if @stream.empty? output << PDF::Core.pdf_object(data) << "\n" else output << PDF::Core.pdf_object(data.merge(@stream.data)) << "\n" << @stream.object end output << "endobj\n" 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.
112 113 114 115 |
# File 'lib/pdf/core/reference.rb', line 112 def replace(other_ref) @data = other_ref.data @stream = other_ref.stream 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
80 81 82 |
# File 'lib/pdf/core/reference.rb', line 80 def to_s "#{@identifier} #{gen} R" end |