Class: Pdfrb::Model::Reference
- Inherits:
-
Object
- Object
- Pdfrb::Model::Reference
- Includes:
- Comparable
- Defined in:
- lib/pdfrb/model/reference.rb
Overview
A pointer to an indirect object (s7.3.10). Value-equal by (oid, gen) so it can be a Hash key. Stored inside dictionaries/arrays wherever an indirect reference appears in source.
Instance Attribute Summary collapse
-
#gen ⇒ Object
readonly
Returns the value of attribute gen.
-
#oid ⇒ Object
readonly
Returns the value of attribute oid.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#deref(document) ⇒ Object
Resolve via the document's object reader.
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(oid, gen = 0) ⇒ Reference
constructor
A new instance of Reference.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(oid, gen = 0) ⇒ Reference
Returns a new instance of Reference.
13 14 15 16 17 |
# File 'lib/pdfrb/model/reference.rb', line 13 def initialize(oid, gen = 0) @oid = oid.to_i @gen = gen.to_i freeze end |
Instance Attribute Details
#gen ⇒ Object (readonly)
Returns the value of attribute gen.
11 12 13 |
# File 'lib/pdfrb/model/reference.rb', line 11 def gen @gen end |
#oid ⇒ Object (readonly)
Returns the value of attribute oid.
11 12 13 |
# File 'lib/pdfrb/model/reference.rb', line 11 def oid @oid end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 22 23 |
# File 'lib/pdfrb/model/reference.rb', line 19 def <=>(other) return nil unless other.is_a?(Reference) [oid, gen] <=> [other.oid, other.gen] end |
#deref(document) ⇒ Object
Resolve via the document's object reader. Returns an Object.
44 45 46 |
# File 'lib/pdfrb/model/reference.rb', line 44 def deref(document) document.object(self) end |
#eql?(other) ⇒ Boolean Also known as: ==
29 30 31 |
# File 'lib/pdfrb/model/reference.rb', line 29 def eql?(other) other.is_a?(Reference) && oid == other.oid && gen == other.gen end |
#hash ⇒ Object
25 26 27 |
# File 'lib/pdfrb/model/reference.rb', line 25 def hash [oid, gen].hash end |
#inspect ⇒ Object
39 40 41 |
# File 'lib/pdfrb/model/reference.rb', line 39 def inspect "#<Pdfrb::Model::Reference oid=#{oid} gen=#{gen}>" end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/pdfrb/model/reference.rb', line 35 def to_s "#{oid} #{gen} R" end |