Class: Uniword::Docx::RawPart
Overview
A package part no Ooxml::PartDefinition models, carried verbatim for round-trip fidelity (e.g. docProps/meta.xml, glossary documents, VBA projects, unmodelled .rels sidecars).
Unlike document-scoped parts (charts, images, embeddings), a raw
part keeps its full package-relative path — raw parts live
anywhere in the package, not only under word/. Content is the
exact source byte stream (binary-safe; never parsed or
re-encoded), plus the content type the source
[Content_Types].xml declared for it (Override first, then
Default by extension; nil when the source declared neither).
The relationship referencing the part (when one exists in a modelled .rels part) is recorded as +r_id+/+rel_type+ metadata for introspection parity with other part kinds; emission never uses it — relationships re-serialize from the loaded rels models, so the source rel survives untouched.
Raw parts are a fallback: PartLoader claims every registry-known path first and RawPartLoader carries only the remainder, so a part is never emitted twice.
Constant Summary
Constants inherited from Part
Instance Attribute Summary collapse
-
#path ⇒ String?
Package-relative path of the emitted part, carried verbatim (overrides Part's word/-prefixed target derivation).
Attributes inherited from Part
#content, #content_type, #definition, #r_id, #rel_type, #target
Class Method Summary collapse
-
.from_hash(hash) ⇒ RawPart
Wrap a raw-hash entry ({ path:, content:, content_type: }) into a RawPart.
Instance Method Summary collapse
-
#initialize(path: nil, content: nil, content_type: nil, r_id: nil, rel_type: nil) ⇒ RawPart
constructor
A new instance of RawPart.
Methods inherited from Part
Constructor Details
#initialize(path: nil, content: nil, content_type: nil, r_id: nil, rel_type: nil) ⇒ RawPart
Returns a new instance of RawPart.
47 48 49 50 51 52 |
# File 'lib/uniword/docx/raw_part.rb', line 47 def initialize(path: nil, content: nil, content_type: nil, r_id: nil, rel_type: nil) super(content: content, content_type: content_type, r_id: r_id, rel_type: rel_type) @path = path end |
Instance Attribute Details
#path ⇒ String?
Package-relative path of the emitted part, carried verbatim (overrides Part's word/-prefixed target derivation).
70 71 72 |
# File 'lib/uniword/docx/raw_part.rb', line 70 def path @path end |
Class Method Details
.from_hash(hash) ⇒ RawPart
Wrap a raw-hash entry ({ path:, content:, content_type: }) into a RawPart. Used by PartCollection to normalize hash assignments.
60 61 62 63 64 |
# File 'lib/uniword/docx/raw_part.rb', line 60 def self.from_hash(hash) new(path: hash[:path], content: hash[:content], content_type: hash[:content_type], r_id: hash[:r_id], rel_type: hash[:rel_type]) end |