Class: PDF::Reader::Reference
- Inherits:
-
Object
- Object
- PDF::Reader::Reference
- Defined in:
- lib/pdf/reader/reference.rb
Overview
An internal PDF::Reader class that represents an indirect reference to a PDF Object
Instance Attribute Summary collapse
-
#gen ⇒ Object
readonly
Returns the value of attribute gen.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#==(obj) ⇒ Object
(also: #eql?)
returns true if the provided object points to the same PDF Object as the current object.
-
#hash ⇒ Object
returns a hash based on the PDF::Reference this object points to.
-
#initialize(id, gen) ⇒ Reference
constructor
Create a new Reference to an object with the specified id and revision number.
-
#to_a ⇒ Object
returns the current Reference object in an array with a single element.
-
#to_i ⇒ Object
returns the ID of this reference.
Constructor Details
#initialize(id, gen) ⇒ Reference
Create a new Reference to an object with the specified id and revision number
35 36 37 |
# File 'lib/pdf/reader/reference.rb', line 35 def initialize (id, gen) @id, @gen = id, gen end |
Instance Attribute Details
#gen ⇒ Object (readonly)
Returns the value of attribute gen.
32 33 34 |
# File 'lib/pdf/reader/reference.rb', line 32 def gen @gen end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
32 33 34 |
# File 'lib/pdf/reader/reference.rb', line 32 def id @id end |
Instance Method Details
#==(obj) ⇒ Object Also known as: eql?
returns true if the provided object points to the same PDF Object as the current object
51 52 53 54 55 |
# File 'lib/pdf/reader/reference.rb', line 51 def ==(obj) return false unless obj.kind_of?(PDF::Reader::Reference) self.hash == obj.hash end |
#hash ⇒ Object
returns a hash based on the PDF::Reference this object points to. Two different Reference objects that point to the same PDF Object will return an identical hash
61 62 63 |
# File 'lib/pdf/reader/reference.rb', line 61 def hash "#{self.id}:#{self.gen}".hash end |
#to_a ⇒ Object
returns the current Reference object in an array with a single element
40 41 42 |
# File 'lib/pdf/reader/reference.rb', line 40 def to_a [self] end |
#to_i ⇒ Object
returns the ID of this reference. Use with caution, ignores the generation id
45 46 47 |
# File 'lib/pdf/reader/reference.rb', line 45 def to_i self.id end |