Method: PDF::Reader::ObjectHash#deref_integer
- Defined in:
- lib/pdf/reader/object_hash.rb
#deref_integer(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 an Integer 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.
Some effort to cast to an int is made when the reference points to a non-integer. : (untyped) -> Integer?
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/pdf/reader/object_hash.rb', line 221 def deref_integer(key) obj = deref(key) return obj if obj.nil? if !obj.is_a?(Integer) if obj.respond_to?(:to_i) obj = obj.to_i else raise MalformedPDFError, "expected object to be an Integer" end end obj end |