Class: Uniword::Docx::PartLoader::LoadContext
- Inherits:
-
Object
- Object
- Uniword::Docx::PartLoader::LoadContext
- Defined in:
- lib/uniword/docx/part_loader/load_context.rb
Overview
Shared state for one package load: the extracted ZIP entries, the package being populated, and the main-document paths resolved from the package-level relationships.
Instance Attribute Summary collapse
-
#package ⇒ Package
readonly
Package being populated.
-
#zip_content ⇒ Hash
readonly
Extracted ZIP entries (package path => content).
-
#zip_path ⇒ String?
readonly
Original ZIP path for binary re-extraction.
Instance Method Summary collapse
-
#initialize(zip_content:, package:, zip_path: nil) ⇒ LoadContext
constructor
A new instance of LoadContext.
-
#main_document_path ⇒ String?
Main document part path, resolved from the package-level officeDocument relationship.
-
#main_document_rels_path ⇒ String?
Relationships part path of the main document, derived from its resolved path.
-
#matching_paths(definition) ⇒ Array<String>
Zip entry paths matching the definition's fixed path or path pattern (numbered part families).
Constructor Details
#initialize(zip_content:, package:, zip_path: nil) ⇒ LoadContext
Returns a new instance of LoadContext.
23 24 25 26 27 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 23 def initialize(zip_content:, package:, zip_path: nil) @zip_content = zip_content @package = package @zip_path = zip_path end |
Instance Attribute Details
#package ⇒ Package (readonly)
Returns package being populated.
14 15 16 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 14 def package @package end |
#zip_content ⇒ Hash (readonly)
Returns extracted ZIP entries (package path => content).
11 12 13 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 11 def zip_content @zip_content end |
#zip_path ⇒ String? (readonly)
Returns original ZIP path for binary re-extraction.
18 19 20 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 18 def zip_path @zip_path end |
Instance Method Details
#main_document_path ⇒ String?
Main document part path, resolved from the package-level officeDocument relationship.
42 43 44 45 46 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 42 def main_document_path return @main_document_path if defined?(@main_document_path) @main_document_path = find_main_document_path end |
#main_document_rels_path ⇒ String?
Relationships part path of the main document, derived from its resolved path.
52 53 54 55 56 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 52 def main_document_rels_path return @main_document_rels_path if defined?(@main_document_rels_path) @main_document_rels_path = sidecar_rels_path(main_document_path) end |
#matching_paths(definition) ⇒ Array<String>
Zip entry paths matching the definition's fixed path or path pattern (numbered part families).
34 35 36 |
# File 'lib/uniword/docx/part_loader/load_context.rb', line 34 def matching_paths(definition) zip_content.keys.select { |path| definition.match_path?(path) } end |