Class: Sevgi::Graphics::Document::Profile

Inherits:
Object
  • Object
show all
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.

See Also:

  • Sevgi::Graphics.document

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes: nil, preambles: nil) ⇒ void

Creates profile metadata.

Parameters:

  • name (Object, nil)

    profile name

  • attributes (Hash, nil) (defaults to: nil)

    default root attributes; nil means an empty Hash

  • preambles (Array<String>, nil) (defaults to: nil)

    preamble lines

Raises:

  • (Sevgi::ArgumentError)

    when name or metadata is invalid XML, cyclic, or cannot be stringified



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

#nameSymbol? (readonly)

Returns profile name.

Returns:

  • (Symbol, nil)

    profile name



335
336
337
# File 'lib/sevgi/graphics/document.rb', line 335

def name
  @name
end

Instance Method Details

#attributesHash{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.

Returns:

  • (Hash{Symbol => Object})

    mutation-isolated attribute snapshot



363
# File 'lib/sevgi/graphics/document.rb', line 363

def attributes = Snapshot.copy(@attributes)

#deconstructArray<(Symbol, nil), Hash, (Array<String>, nil)>

Returns profile components.

Returns:

  • (Array<(Symbol, nil), Hash, (Array<String>, nil)>)


367
# File 'lib/sevgi/graphics/document.rb', line 367

def deconstruct = [name, attributes, preambles]

#eql?(other) ⇒ Boolean Also known as: ==

Reports strict profile equality.

Parameters:

  • other (Object)

    object to compare

Returns:

  • (Boolean)


353
# File 'lib/sevgi/graphics/document.rb', line 353

def eql?(other) = self.class == other.class && deconstruct == other.deconstruct

#hashInteger

Returns a hash compatible with strict equality.

Returns:

  • (Integer)


357
# File 'lib/sevgi/graphics/document.rb', line 357

def hash = [self.class, name, @attributes, @preambles].hash

#preamblesArray<String>?

Returns preamble lines.

Returns:

  • (Array<String>, nil)

    mutation-isolated preamble snapshot



371
# File 'lib/sevgi/graphics/document.rb', line 371

def preambles = Snapshot.copy(@preambles)