Method: PDF::Reader::ObjectHash#deref_name_or_array
- Defined in:
- lib/pdf/reader/object_hash.rb
#deref_name_or_array(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 PDF Name (symbol), Array or nil. If the dereference results in any other type then a MalformedPDFError exception will raise. Useful when expecting a Name or Array and no other type will do.
283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/pdf/reader/object_hash.rb', line 283 def deref_name_or_array(key) obj = deref(key) return obj if obj.nil? obj.tap { |obj| if !obj.is_a?(Symbol) && !obj.is_a?(Array) raise MalformedPDFError, "expected object to be an Array or Name" end } end |