Module: Sevgi::Graphics::Attribute::Ident Private

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 identifier helpers.

Instance Method Summary collapse

Instance Method Details

#id(given) ⇒ Symbol

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 normalized attribute id.

Parameters:

  • given (String, Symbol)

    attribute name

Returns:

  • (Symbol)


34
35
36
37
38
39
40
# File 'lib/sevgi/graphics/attribute.rb', line 34

def id(given)
  (@id ||= {})[given] ||= begin
    name = updateable?(given) ? key(given).delete_suffix(Attributes::UPDATE_SUFFIX) : key(given)
    XML.name(name, context: "XML attribute name") unless internal?(given)
    name.to_sym
  end
end

#internal?(given) ⇒ Boolean

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.

Reports whether an attribute is internal to Sevgi rendering.

Parameters:

  • given (String, Symbol)

    attribute name

Returns:

  • (Boolean)


27
28
29
# File 'lib/sevgi/graphics/attribute.rb', line 27

def internal?(given)
  (@internal ||= {})[given] ||= key(given).start_with?(Attributes::META_PREFIX)
end

#updateable?(given) ⇒ Boolean

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.

Reports whether an attribute uses merge/update syntax.

Parameters:

  • given (String, Symbol)

    attribute name

Returns:

  • (Boolean)


45
46
47
# File 'lib/sevgi/graphics/attribute.rb', line 45

def updateable?(given)
  (@updateable ||= {})[given] ||= key(given).end_with?(Attributes::UPDATE_SUFFIX)
end