Module: Kreuzberg::FormatMetadata
- Extended by:
- T::Helpers, T::Sig
- Included in:
- FormatMetadataArchive, FormatMetadataAudio, FormatMetadataBibtex, FormatMetadataCitation, FormatMetadataCsv, FormatMetadataDbf, FormatMetadataDocx, FormatMetadataEmail, FormatMetadataEpub, FormatMetadataExcel, FormatMetadataFictionBook, FormatMetadataHtml, FormatMetadataImage, FormatMetadataJats, FormatMetadataOcr, FormatMetadataPdf, FormatMetadataPptx, FormatMetadataPst, FormatMetadataText, FormatMetadataXml
- Defined in:
- lib/kreuzberg/native.rb
Overview
Format-specific metadata (discriminated union).
Only one format type can exist per extraction result. This provides type-safe, clean metadata without nested optionals.
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
# File 'lib/kreuzberg/native.rb', line 1999 def self.from_hash(hash) discriminator = hash[:format_type] || hash["format_type"] case discriminator when "pdf" then FormatMetadataPdf.from_hash(hash) when "docx" then FormatMetadataDocx.from_hash(hash) when "excel" then FormatMetadataExcel.from_hash(hash) when "email" then FormatMetadataEmail.from_hash(hash) when "pptx" then FormatMetadataPptx.from_hash(hash) when "archive" then FormatMetadataArchive.from_hash(hash) when "image" then FormatMetadataImage.from_hash(hash) when "xml" then FormatMetadataXml.from_hash(hash) when "text" then FormatMetadataText.from_hash(hash) when "html" then FormatMetadataHtml.from_hash(hash) when "ocr" then FormatMetadataOcr.from_hash(hash) when "csv" then FormatMetadataCsv.from_hash(hash) when "bibtex" then FormatMetadataBibtex.from_hash(hash) when "citation" then FormatMetadataCitation.from_hash(hash) when "fiction_book" then FormatMetadataFictionBook.from_hash(hash) when "dbf" then FormatMetadataDbf.from_hash(hash) when "jats" then FormatMetadataJats.from_hash(hash) when "epub" then FormatMetadataEpub.from_hash(hash) when "pst" then FormatMetadataPst.from_hash(hash) when "audio" then FormatMetadataAudio.from_hash(hash) else raise "Unknown discriminator: #{discriminator}" end end |