Class: PDF::Reader::Reference

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(id, gen) ⇒ Reference

Create a new Reference to an object with the specified id and revision number



36
37
38
# File 'lib/pdf/reader/reference.rb', line 36

def initialize(id, gen)
  @id, @gen = id, gen
end

Instance Attribute Details

#genObject (readonly)

Returns the value of attribute gen.



33
34
35
# File 'lib/pdf/reader/reference.rb', line 33

def gen
  @gen
end

#idObject (readonly)

Returns the value of attribute id.



33
34
35
# File 'lib/pdf/reader/reference.rb', line 33

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



52
53
54
55
56
# File 'lib/pdf/reader/reference.rb', line 52

def ==(obj)
  return false unless obj.kind_of?(PDF::Reader::Reference)

  self.hash == obj.hash
end

#hashObject

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



62
63
64
# File 'lib/pdf/reader/reference.rb', line 62

def hash
  "#{self.id}:#{self.gen}".hash
end

#to_aObject

returns the current Reference object in an array with a single element



41
42
43
# File 'lib/pdf/reader/reference.rb', line 41

def to_a
  [self]
end

#to_iObject

returns the ID of this reference. Use with caution, ignores the generation id



46
47
48
# File 'lib/pdf/reader/reference.rb', line 46

def to_i
  self.id
end