Class: Sumi::Graphics::Document::Profile
- Inherits:
-
Object
- Object
- Sumi::Graphics::Document::Profile
- Defined in:
- graphics/lib/sumi/graphics/document.rb
Overview
Immutable, read-only document profile metadata exposed by document classes. Process-global lookup and registration are thread-atomic. Metadata containers and strings are captured recursively. Other mutable attribute values are stringified once during construction. Attribute names and nested Hash keys are normalized to Symbols, nil values are omitted, and update-suffix intent is retained for inheritance. Returned attribute and preamble collections are caller-owned snapshots, so changing them does not alter the registered profile.
Instance Attribute Summary collapse
-
#name ⇒ Symbol?
readonly
Profile name.
Instance Method Summary collapse
-
#attributes ⇒ Hash{Symbol => Object}
Returns canonical default root attributes for this profile.
-
#deconstruct ⇒ Array<(Symbol, nil), Hash, (Array<String>, nil)>
Returns profile components.
-
#eql?(other) ⇒ Boolean
(also: #==)
Reports strict profile equality.
-
#hash ⇒ Integer
Returns a hash compatible with strict equality.
-
#initialize(name, attributes: nil, preambles: nil) ⇒ void
constructor
Creates profile metadata.
-
#preambles ⇒ Array<String>?
Returns preamble lines.
Constructor Details
#initialize(name, attributes: nil, preambles: nil) ⇒ void
Creates profile metadata.
264 265 266 267 268 269 |
# File 'graphics/lib/sumi/graphics/document.rb', line 264 def initialize(name, attributes: nil, preambles: nil) @name = name.nil? ? nil : Name.normalize!(name) @attributes = capture_attributes(attributes) @preambles = capture_preambles(preambles) freeze end |
Instance Attribute Details
#name ⇒ Symbol? (readonly)
Returns profile name.
256 257 258 |
# File 'graphics/lib/sumi/graphics/document.rb', line 256 def name @name end |
Instance Method Details
#attributes ⇒ Hash{Symbol => Object}
Returns canonical default root attributes for this profile. Names and nested Hash keys are Symbols, nil attributes are omitted, and update suffixes remain explicit for application by a document class.
284 |
# File 'graphics/lib/sumi/graphics/document.rb', line 284 def attributes = Snapshot.copy(@attributes) |
#deconstruct ⇒ Array<(Symbol, nil), Hash, (Array<String>, nil)>
Returns profile components.
288 |
# File 'graphics/lib/sumi/graphics/document.rb', line 288 def deconstruct = [name, attributes, preambles] |
#eql?(other) ⇒ Boolean Also known as: ==
Reports strict profile equality.
274 |
# File 'graphics/lib/sumi/graphics/document.rb', line 274 def eql?(other) = self.class == other.class && deconstruct == other.deconstruct |
#hash ⇒ Integer
Returns a hash compatible with strict equality.
278 |
# File 'graphics/lib/sumi/graphics/document.rb', line 278 def hash = [self.class, name, @attributes, @preambles].hash |
#preambles ⇒ Array<String>?
Returns preamble lines.
292 |
# File 'graphics/lib/sumi/graphics/document.rb', line 292 def preambles = Snapshot.copy(@preambles) |