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.
348 349 350 351 352 353 354 355 356 357 |
# File 'lib/pdf/reader/object_hash.rb', line 348 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 |