Class: Pdfh::Document
- Inherits:
-
Object
- Object
- Pdfh::Document
- Defined in:
- lib/pdfh/models/document.rb
Overview
Lightweight struct that connects a PDF file with its matched document type and extracted text. All file metadata, date interpretation, and rename resolution are accessible through dedicated value objects (FileInfo, DateInfo).
Instance Attribute Summary collapse
-
#date_info ⇒ Object
readonly
Returns the value of attribute date_info.
-
#file_info ⇒ FileInfo
readonly
File metadata wrapper.
-
#text ⇒ String
readonly
Extracted text from the PDF.
-
#type ⇒ DocumentType
readonly
Matched document type.
Instance Method Summary collapse
-
#initialize(file, type, text, date_captures) ⇒ self
constructor
A new Document instance.
-
#new_name ⇒ String
New file name with extension (e.g., "2024-01 Cuenta.pdf").
-
#store_path ⇒ String
Storage path for the document (e.g., "2024/Edo Cuenta").
-
#to_s ⇒ String
File name.
-
#type_name ⇒ String
Document type name or "N/A" if type is nil.
Constructor Details
Instance Attribute Details
#date_info ⇒ Object (readonly)
Returns the value of attribute date_info.
16 |
# File 'lib/pdfh/models/document.rb', line 16 attr_reader :file_info, :type, :text, :date_info |
#file_info ⇒ FileInfo (readonly)
Returns File metadata wrapper.
16 17 18 |
# File 'lib/pdfh/models/document.rb', line 16 def file_info @file_info end |
#text ⇒ String (readonly)
Returns Extracted text from the PDF.
16 |
# File 'lib/pdfh/models/document.rb', line 16 attr_reader :file_info, :type, :text, :date_info |
#type ⇒ DocumentType (readonly)
Returns Matched document type.
16 |
# File 'lib/pdfh/models/document.rb', line 16 attr_reader :file_info, :type, :text, :date_info |
Instance Method Details
#new_name ⇒ String
Returns New file name with extension (e.g., "2024-01 Cuenta.pdf").
41 42 43 |
# File 'lib/pdfh/models/document.rb', line 41 def new_name "#{@type.name_validator.gsub(rename_data)}#{@file_info.extension}" end |
#store_path ⇒ String
Returns Storage path for the document (e.g., "2024/Edo Cuenta").
46 47 48 |
# File 'lib/pdfh/models/document.rb', line 46 def store_path @type.path_validator.gsub(rename_data) end |
#to_s ⇒ String
Returns File name.
36 37 38 |
# File 'lib/pdfh/models/document.rb', line 36 def to_s file_info.name end |
#type_name ⇒ String
Returns Document type name or "N/A" if type is nil.
31 32 33 |
# File 'lib/pdfh/models/document.rb', line 31 def type_name type&.name || "N/A" end |