Method: PDF::Reader::ObjectHash#deref_hash

Defined in:
lib/pdf/reader/object_hash.rb

#deref_hash(key) ⇒ Object

If key is a PDF::Reader::Reference object, lookup the corresponding object in the PDF and return it. Otherwise return key untouched.

Guaranteed to only return a Hash or nil. If the dereference results in any other type then a MalformedPDFError exception will raise. Useful when expecting an Array and no other type will do. : (untyped) -> Hash[Symbol, untyped]?



177
178
179
180
181
182
183
184
185
# File 'lib/pdf/reader/object_hash.rb', line 177

def deref_hash(key)
  obj = deref(key)

  return obj if obj.nil?

  obj.tap { |obj|
    raise MalformedPDFError, "expected object to be a Hash or nil" if !obj.is_a?(Hash)
  }
end