Module: HexaPDF::DictionaryFields::FileSpecificationConverter
- Defined in:
- lib/hexapdf/dictionary_fields.rb
Overview
Converter module for file specification fields. A file specification in string format is converted to the corresponding file specification dictionary.
See: PDF2.0 s7.11, HexaPDF::Type::FileSpecification
Class Method Summary collapse
-
.additional_types ⇒ Object
Filespecs can also be simple hashes or strings.
-
.convert(data, type, document) ⇒ Object
Converts a string file specification or a hash into a full file specification.
-
.usable_for?(type) ⇒ Boolean
This converter is only used for the :Filespec type.
Class Method Details
.additional_types ⇒ Object
Filespecs can also be simple hashes or strings.
353 354 355 |
# File 'lib/hexapdf/dictionary_fields.rb', line 353 def self.additional_types [Hash, String] end |
.convert(data, type, document) ⇒ Object
Converts a string file specification or a hash into a full file specification. Otherwise returns nil
.
359 360 361 362 363 364 365 |
# File 'lib/hexapdf/dictionary_fields.rb', line 359 def self.convert(data, type, document) return if data.kind_of?(type.first) || !(data.kind_of?(Hash) || data.kind_of?(HexaPDF::Dictionary) || data.kind_of?(String)) data = {F: data} if data.kind_of?(String) document.wrap(data, type: type.first) end |
.usable_for?(type) ⇒ Boolean
This converter is only used for the :Filespec type.
348 349 350 |
# File 'lib/hexapdf/dictionary_fields.rb', line 348 def self.usable_for?(type) type == :Filespec end |