Class: Lutaml::Model::Xml::XmlNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/xml/xml_namespace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil, prefix = nil) ⇒ XmlNamespace

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.

Initialize instance

Parameters:

  • name (String, nil)
  • prefix (String, nil) (defaults to: nil)


27
28
29
30
# File 'lib/lutaml/model/xml/xml_namespace.rb', line 27

def initialize(uri = nil, prefix = nil)
  @uri = uri
  @prefix = normalize_prefix(prefix)
end

Instance Attribute Details

#prefixString

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.

Return prefix

Returns:

  • (String)


19
20
21
# File 'lib/lutaml/model/xml/xml_namespace.rb', line 19

def prefix
  @prefix
end

#uriString

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.

Return name

Returns:

  • (String)


12
13
14
# File 'lib/lutaml/model/xml/xml_namespace.rb', line 12

def uri
  @uri
end

Instance Method Details

#attr_nameObject



39
40
41
42
43
44
45
# File 'lib/lutaml/model/xml/xml_namespace.rb', line 39

def attr_name
  if Utils.present?(prefix)
    "xmlns:#{prefix}"
  else
    "xmlns"
  end
end

#normalize_prefix(prefix) ⇒ Object



32
33
34
35
36
37
# File 'lib/lutaml/model/xml/xml_namespace.rb', line 32

def normalize_prefix(prefix)
  normalized_prefix = prefix.to_s.gsub(/xmlns:?/, "")
  return if normalized_prefix.empty?

  normalized_prefix
end