Module: HexaPDF::DictionaryFields::RectangleConverter

Defined in:
lib/hexapdf/dictionary_fields.rb

Overview

Converter module for fields of type Rectangle.

See: PDF2.0 s7.9.5

Class Method Summary collapse

Class Method Details

.additional_typesObject

Rectangle fields can also contain simple arrays.



380
381
382
# File 'lib/hexapdf/dictionary_fields.rb', line 380

def self.additional_types
  Array
end

.convert(data, _type, document) ⇒ Object

Wraps a given array using the Rectangle class or as a Null value if the array is invalid. Otherwise returns nil.



386
387
388
389
# File 'lib/hexapdf/dictionary_fields.rb', line 386

def self.convert(data, _type, document)
  return unless data.kind_of?(Array) || data.kind_of?(HexaPDF::PDFArray)
  data.empty? ? document.wrap(nil) : document.wrap(data, type: Rectangle)
end

.usable_for?(type) ⇒ Boolean

This converter is usable if the type is Rectangle.

Returns:



375
376
377
# File 'lib/hexapdf/dictionary_fields.rb', line 375

def self.usable_for?(type)
  type == Rectangle
end