Class: PDF::Core::Reference
- Inherits:
-
Object
- Object
- PDF::Core::Reference
- Defined in:
- lib/pdf/core/reference.rb
Overview
:nodoc:
Defined Under Namespace
Classes: CannotAttachStream
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#gen ⇒ Object
Returns the value of attribute gen.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#stream ⇒ Object
Returns the value of attribute stream.
Instance Method Summary collapse
- #<<(io) ⇒ Object
-
#deep_copy(share = []) ⇒ Object
Creates a deep copy of this ref.
-
#initialize(id, data) ⇒ Reference
constructor
A new instance of Reference.
- #object ⇒ Object
-
#replace(other_ref) ⇒ Object
Replaces the data and stream with that of other_ref.
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
14 15 16 |
# File 'lib/pdf/core/reference.rb', line 14 def data @data end |
#gen ⇒ Object
Returns the value of attribute gen.
14 15 16 |
# File 'lib/pdf/core/reference.rb', line 14 def gen @gen end |
#identifier ⇒ Object
Returns the value of attribute identifier.
14 15 16 |
# File 'lib/pdf/core/reference.rb', line 14 def identifier @identifier end |
#offset ⇒ Object
Returns the value of attribute offset.
14 15 16 |
# File 'lib/pdf/core/reference.rb', line 14 def offset @offset end |
#stream ⇒ Object
Returns the value of attribute stream.
14 15 16 |
# File 'lib/pdf/core/reference.rb', line 14 def stream @stream end |
Instance Method Details
#<<(io) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/pdf/core/reference.rb', line 41 def <<(io) unless @data.is_a?(::Hash) raise CannotAttachStream end (@stream ||= Stream.new) << io end |
#deep_copy(share = []) ⇒ Object
Creates a deep copy of this ref. If share
is provided, shares the given dictionary entries between the old ref and the new.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pdf/core/reference.rb', line 56 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 ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pdf/core/reference.rb', line 29 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) ⇒ Object
Replaces the data and stream with that of other_ref.
76 77 78 79 |
# File 'lib/pdf/core/reference.rb', line 76 def replace(other_ref) @data = other_ref.data @stream = other_ref.stream end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/pdf/core/reference.rb', line 49 def to_s "#{@identifier} #{gen} R" end |