Class: Lutaml::Xml::XmlAttribute
- Inherits:
-
Object
- Object
- Lutaml::Xml::XmlAttribute
- Defined in:
- lib/lutaml/xml/xml_attribute.rb
Overview
Represents an XML attribute
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#namespace_prefix ⇒ Object
readonly
Returns the value of attribute namespace_prefix.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value, namespace: nil, namespace_prefix: nil) ⇒ XmlAttribute
constructor
A new instance of XmlAttribute.
- #namespaced_name ⇒ Object
- #unprefixed_name ⇒ Object
Constructor Details
#initialize(name, value, namespace: nil, namespace_prefix: nil) ⇒ XmlAttribute
Returns a new instance of XmlAttribute.
9 10 11 12 13 14 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 9 def initialize(name, value, namespace: nil, namespace_prefix: nil) @name = name @value = value @namespace = namespace @namespace_prefix = namespace_prefix end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 7 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 7 def namespace @namespace end |
#namespace_prefix ⇒ Object (readonly)
Returns the value of attribute namespace_prefix.
7 8 9 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 7 def namespace_prefix @namespace_prefix end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 7 def value @value end |
Instance Method Details
#namespaced_name ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 24 def namespaced_name # For type-namespaced attributes (those with xml_namespace declaration), # return the prefixed name (e.g., "xml:lang", "ex:attr") # rather than URI:name format (e.g., "http://www.w3.org/XML/1998/namespace:lang") if namespace_prefix name elsif namespace "#{namespace}:#{unprefixed_name}" else unprefixed_name end end |
#unprefixed_name ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/lutaml/xml/xml_attribute.rb', line 16 def unprefixed_name if namespace_prefix name.split(":").last else name end end |