Module: Sevgi::Graphics::Attribute Private

Extended by:
Ident
Defined in:
lib/sevgi/graphics/attribute.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Attribute name normalization helpers.

Defined Under Namespace

Modules: Ident Classes: Store

Class Method Summary collapse

Methods included from Ident

id, internal?, updateable?

Class Method Details

.capture(value, normalize_keys: false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Captures a caller-independent attribute value.

Parameters:

  • value (Object)

    value to capture

  • normalize_keys (Boolean) (defaults to: false)

    normalize direct Hash keys to Symbols

Returns:

  • (Object)

    owned mutable snapshot

Raises:

  • (Sevgi::ArgumentError)

    when value is invalid, cyclic, collides, or cannot be converted



126
# File 'lib/sevgi/graphics/attribute.rb', line 126

def self.capture(value, normalize_keys: false) = Snapshot.capture(value, normalize_keys:)

.xml_text(value) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the text form used for an XML attribute value before escaping.

Parameters:

  • value (Object)

    attribute value

Returns:

  • (String)

Raises:

  • (Sevgi::ArgumentError)

    when value is invalid, cyclic, or cannot be stringified as XML



133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/sevgi/graphics/attribute.rb', line 133

def self.xml_text(value)
  value = XML.snapshot(value, context: "XML attribute value")
  text = case value
  when ::Hash
    value.map { |key, attr_value| "#{key}:#{attr_value}" }.join("; ")
  when ::Array
    value.join(" ")
  else
    value.to_s
  end

  XML.text(text, context: "XML attribute value")
end