Class: Sevgi::Graphics::Attributes
- Inherits:
-
Object
- Object
- Sevgi::Graphics::Attributes
- Defined in:
- lib/sevgi/graphics/attribute.rb,
lib/sevgi/graphics/attribute.rb
Overview
Names beginning with META_PREFIX can be read, assigned, deleted, merged, and copied like ordinary attributes. They appear in #to_h, but public SVG attribute enumeration and rendered XML omit them. All values entering or leaving this facade are recursively owned snapshots. Appending UPDATE_SUFFIX to a name requests a same-family update: Strings and Symbols are space-joined, Arrays are concatenated, and Hashes are merged. An update to an absent name behaves as replacement, and nil assignments are ignored.
Constant Summary collapse
- META_PREFIX =
Prefix marking supported non-rendering metadata names. Prefixed entries remain available through the facade but are omitted from SVG output.
"-"- UPDATE_SUFFIX =
Suffix requesting an update of an existing value. String and Symbol values are space-joined, Arrays are concatenated, and Hashes are merged. When the attribute is absent, assignment uses normal replacement behavior.
"+"
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Returns an owned snapshot of an attribute value.
-
#[]=(key, value) ⇒ Object?
Assigns or updates a recursively owned attribute value.
-
#delete(key) ⇒ Object?
Deletes an attribute and returns an owned snapshot of its value.
-
#has?(key) ⇒ Boolean
Reports whether an attribute exists.
-
#initialize(attributes = {}) ⇒ void
constructor
Creates an attribute facade from recursively owned snapshots.
-
#keys ⇒ Array<Symbol>
Returns rendering attribute names, excluding non-rendering metadata.
-
#merge!(attributes) ⇒ Sevgi::Graphics::Attributes
Atomically assigns or updates recursively owned attributes.
-
#to_h ⇒ Hash{Symbol => Object}
Returns a recursively owned Hash snapshot including non-rendering metadata.
Constructor Details
Instance Method Details
#[](key) ⇒ Object?
Returns an owned snapshot of an attribute value.
353 |
# File 'lib/sevgi/graphics/attribute.rb', line 353 def [](key) = snapshot(@store[key]) |
#[]=(key, value) ⇒ Object?
Assigns or updates a recursively owned attribute value.
361 362 363 364 |
# File 'lib/sevgi/graphics/attribute.rb', line 361 def []=(key, value) @store[key] = value snapshot(@store[key]) end |
#delete(key) ⇒ Object?
Deletes an attribute and returns an owned snapshot of its value.
370 |
# File 'lib/sevgi/graphics/attribute.rb', line 370 def delete(key) = snapshot(@store.delete(key)) |
#has?(key) ⇒ Boolean
Reports whether an attribute exists.
376 |
# File 'lib/sevgi/graphics/attribute.rb', line 376 def has?(key) = @store.has?(key) |
#keys ⇒ Array<Symbol>
Returns rendering attribute names, excluding non-rendering metadata.
392 |
# File 'lib/sevgi/graphics/attribute.rb', line 392 def keys = @store.list.freeze |
#merge!(attributes) ⇒ Sevgi::Graphics::Attributes
Atomically assigns or updates recursively owned attributes.
399 400 401 402 |
# File 'lib/sevgi/graphics/attribute.rb', line 399 def merge!(attributes) @store.import(attributes) self end |
#to_h ⇒ Hash{Symbol => Object}
Returns a recursively owned Hash snapshot including non-rendering metadata.
406 |
# File 'lib/sevgi/graphics/attribute.rb', line 406 def to_h = snapshot(@store.to_h) |