Class: Lutaml::Model::Type::QName
- Defined in:
- lib/lutaml/model/type/qname.rb
Overview
QName (Qualified Name) type
Represents XML qualified names in prefix:localName format
Constant Summary
Constants inherited from Value
Instance Attribute Summary collapse
-
#local_name ⇒ Object
readonly
Returns the value of attribute local_name.
-
#namespace_uri ⇒ Object
Returns the value of attribute namespace_uri.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Attributes inherited from Value
Class Method Summary collapse
- .cast(value, _options = {}) ⇒ Object
-
.default_xsd_type ⇒ String
XSD type for QName.
-
.from_parts(local_name:, prefix: nil, namespace_uri: nil) ⇒ QName
Create QName from components.
- .serialize(value) ⇒ Object
Instance Method Summary collapse
-
#initialize(value) ⇒ QName
constructor
A new instance of QName.
- #to_s ⇒ Object
Methods inherited from Value
format_type_serializer_for, from_format, #initialized?, register_format_to_from_methods, register_format_type_serializer
Methods included from Xml::Type::Configurable
Methods included from UninitializedClassGuard
Constructor Details
#initialize(value) ⇒ QName
Returns a new instance of QName.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lutaml/model/type/qname.rb', line 16 def initialize(value) if value.is_a?(QName) @prefix = value.prefix @local_name = value.local_name @namespace_uri = value.namespace_uri @value = value.to_s else @value = self.class.cast(value) parse_qname(@value) if @value end end |
Instance Attribute Details
#local_name ⇒ Object (readonly)
Returns the value of attribute local_name.
13 14 15 |
# File 'lib/lutaml/model/type/qname.rb', line 13 def local_name @local_name end |
#namespace_uri ⇒ Object
Returns the value of attribute namespace_uri.
14 15 16 |
# File 'lib/lutaml/model/type/qname.rb', line 14 def namespace_uri @namespace_uri end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
13 14 15 |
# File 'lib/lutaml/model/type/qname.rb', line 13 def prefix @prefix end |
Class Method Details
.cast(value, _options = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/lutaml/model/type/qname.rb', line 28 def self.cast(value, = {}) return nil if value.nil? return value if Utils.uninitialized?(value) return value.to_s if value.is_a?(QName) value.to_s end |
.default_xsd_type ⇒ String
XSD type for QName
46 47 48 |
# File 'lib/lutaml/model/type/qname.rb', line 46 def self.default_xsd_type "xs:QName" end |
.from_parts(local_name:, prefix: nil, namespace_uri: nil) ⇒ QName
Create QName from components
60 61 62 63 64 65 |
# File 'lib/lutaml/model/type/qname.rb', line 60 def self.from_parts(local_name:, prefix: nil, namespace_uri: nil) qname_str = prefix ? "#{prefix}:#{local_name}" : local_name new(qname_str).tap do |qname| qname.namespace_uri = namespace_uri end end |
.serialize(value) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/lutaml/model/type/qname.rb', line 36 def self.serialize(value) return nil if value.nil? return value.to_s if value.is_a?(QName) value.to_s end |
Instance Method Details
#to_s ⇒ Object
50 51 52 |
# File 'lib/lutaml/model/type/qname.rb', line 50 def to_s @value end |