Module: Sevgi::Graphics::Mixtures::Identify

Defined in:
lib/sevgi/graphics/mixtures/identify.rb

Overview

DSL helpers for collecting and hiding SVG ids.

Defined Under Namespace

Classes: Identifiers

Instance Method Summary collapse

Instance Method Details

#DisidentifySevgi::Graphics::Element

Moves visible id attributes to non-rendering -id metadata throughout the subtree. A pre-existing -id takes precedence over the visible id.

Examples:

Hide ids while retaining their source identity

document = Sevgi::Graphics.SVG { rect id: "source-id" }
document.Disidentify
document.children.first[:"-id"] # => "source-id"

Returns:



73
74
75
76
77
78
79
80
81
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 73

def Disidentify
  Traverse do |element|
    next unless element.attributes.has?(:id)

    id = element.attributes.delete(:id)
     = :"#{Attributes::META_PREFIX}id"
    element[] = id unless element.attributes.has?()
  end
end

#IdentifiersSevgi::Graphics::Mixtures::Identify::Identifiers

Builds an immutable id index snapshot for the current element subtree. Rebuild the index to observe later id or tree changes.

Returns:



86
# File 'lib/sevgi/graphics/mixtures/identify.rb', line 86

def Identifiers = Identifiers.new(self)