Module: HexaPDF::DictionaryFields::RectangleConverter

Defined in:
lib/hexapdf/dictionary_fields.rb

Overview

Converter module for fields of type Rectangle.

Class Method Summary collapse

Class Method Details

.additional_typesObject

Rectangle fields can also contain simple arrays.



340
341
342
# File 'lib/hexapdf/dictionary_fields.rb', line 340

def self.additional_types
  Array
end

.convert(data, _type, document) ⇒ Object

Wraps a given array in the Rectangle class. Otherwise returns nil.



345
346
347
348
# File 'lib/hexapdf/dictionary_fields.rb', line 345

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:



335
336
337
# File 'lib/hexapdf/dictionary_fields.rb', line 335

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