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 : (Integer, Integer) -> void



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

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

Instance Attribute Details

#genObject (readonly)

: Integer



38
39
40
# File 'lib/pdf/reader/reference.rb', line 38

def gen
  @gen
end

#idObject (readonly)

: Integer



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

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 : (Object) -> bool



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

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 : () -> Integer



73
74
75
# File 'lib/pdf/reader/reference.rb', line 73

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

#to_aObject

returns the current Reference object in an array with a single element : () -> Array



49
50
51
# File 'lib/pdf/reader/reference.rb', line 49

def to_a
  [self]
end

#to_iObject

returns the ID of this reference. Use with caution, ignores the generation id : () -> Integer



55
56
57
# File 'lib/pdf/reader/reference.rb', line 55

def to_i
  self.id
end