class HexaPDF::DictionaryFields::Field

from its string representation to a Time object.
automatically, like checking for the correct minimum PDF version to use or converting a date
By incorporating this field information into HexaPDF it is possible to do many things
comes directly from the PDF specification.
A field contains information about one field of a structured PDF object and this information

def self.converter_for(type)

appears earlier is used.
the back. So if two converters could potentially be used for the same type, the one that
The converter list from #converters is checked for a suitable converter from the front to

Returns the converter for the given +type+ specification.
def self.converter_for(type)
  @converters.find {|converter| converter.usable_for?(type) }
end

def self.converters

See ::converter_for for information on how this list is used.

Returns the list of available converter objects.
def self.converters
  @converters ||= []
end

def convert(data, document)

Converts the data into a useful object if possible. Otherwise returns +nil+.
def convert(data, document)
  @converters.each do |converter|
    result = converter.convert(data, type, document)
    return result unless result.nil?
  end
  nil
end

def default

Returns a duplicated default value.
def default
  @default.dup
end

def default?

Returns +true+ if a default value is available.
def default?
  !@default.nil?
end

def initialize(type, required: false, default: nil, indirect: nil, allowed_values: nil,

available converters.
Depending on the +type+ entry an appropriate field converter object is chosen from the

Create a new Field object. See Dictionary::define_field for information on the arguments.
def initialize(type, required: false, default: nil, indirect: nil, allowed_values: nil,
               version: nil)
  @type = [type].flatten
  @type_mapped = false
  @required, @default, @indirect, @version = required, default, indirect, version
  @allowed_values = allowed_values && [allowed_values].flatten
  @converters = @type.map {|t| self.class.converter_for(t) }.compact
end

def required?

Returns +true+ if this field is required.
def required?
  @required
end

def type

Returns the array with valid types for this field.
def type
  return @type if @type_mapped
  @type.concat(@converters.flat_map(&:additional_types).compact)
  @type.map! do |type|
    if type.kind_of?(Symbol)
      HexaPDF::GlobalConfiguration.constantize('object.type_map', type)
    else
      type
    end
  end
  @type.uniq!
  @type_mapped = true
  @type
end

def valid_object?(obj)

Returns +true+ if the given object is valid for this field.
def valid_object?(obj)
  type.any? {|t| obj.kind_of?(t) } ||
    (obj.kind_of?(HexaPDF::Object) && type.any? {|t| obj.value.kind_of?(t) })
end