Method: PDF::Reader::ObjectHash#fetch
- Defined in:
- lib/pdf/reader/object_hash.rb
#fetch(key, local_default = nil) ⇒ Object
Access an object from the PDF. key can be an int or a PDF::Reader::Reference object.
If an int is used, the object with that ID and a generation number of 0 will be returned.
If a PDF::Reader::Reference object is used the exact ID and generation number can be specified.
local_default is the object that will be returned if the requested key doesn’t exist.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/pdf/reader/object_hash.rb', line 114 def fetch(key, local_default = nil) obj = self[key] if obj return obj elsif local_default return local_default else raise IndexError, "#{key} is invalid" if key.to_i <= 0 end end |