Class: Sevgi::Graphics::Document::Profile
- Inherits:
-
Object
- Object
- Sevgi::Graphics::Document::Profile
- Defined in:
- lib/sevgi/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.
343 344 345 346 347 348 |
# File 'lib/sevgi/graphics/document.rb', line 343 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.
335 336 337 |
# File 'lib/sevgi/graphics/document.rb', line 335 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.
363 |
# File 'lib/sevgi/graphics/document.rb', line 363 def attributes = Snapshot.copy(@attributes) |
#deconstruct ⇒ Array<(Symbol, nil), Hash, (Array<String>, nil)>
Returns profile components.
367 |
# File 'lib/sevgi/graphics/document.rb', line 367 def deconstruct = [name, attributes, preambles] |
#eql?(other) ⇒ Boolean Also known as: ==
Reports strict profile equality.
353 |
# File 'lib/sevgi/graphics/document.rb', line 353 def eql?(other) = self.class == other.class && deconstruct == other.deconstruct |
#hash ⇒ Integer
Returns a hash compatible with strict equality.
357 |
# File 'lib/sevgi/graphics/document.rb', line 357 def hash = [self.class, name, @attributes, @preambles].hash |
#preambles ⇒ Array<String>?
Returns preamble lines.
371 |
# File 'lib/sevgi/graphics/document.rb', line 371 def preambles = Snapshot.copy(@preambles) |