Class: Lutaml::Model::Type::Uri
- Defined in:
- lib/lutaml/model/type/uri.rb
Overview
URI type for xs:anyURI
Validates and handles URI values.
Constant Summary
Constants inherited from Value
Instance Attribute Summary
Attributes inherited from Value
Class Method Summary collapse
- .cast(value, _options = {}) ⇒ Object
-
.default_xsd_type ⇒ String
XSD type for Uri.
- .serialize(value) ⇒ Object
-
.valid_uri?(value) ⇒ Boolean
Validate URI format.
Methods inherited from Value
format_type_serializer_for, from_format, #initialize, #initialized?, register_format_to_from_methods, register_format_type_serializer, #to_s
Methods included from Xml::Type::Configurable
Methods included from UninitializedClassGuard
Constructor Details
This class inherits a constructor from Lutaml::Model::Type::Value
Class Method Details
.cast(value, _options = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/lutaml/model/type/uri.rb', line 15 def self.cast(value, = {}) return nil if value.nil? return value if Utils.uninitialized?(value) return value if value.is_a?(::URI) return value if value.is_a?(::String) value.to_s end |
.default_xsd_type ⇒ String
XSD type for Uri
34 35 36 |
# File 'lib/lutaml/model/type/uri.rb', line 34 def self.default_xsd_type "xs:anyURI" end |
.serialize(value) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/lutaml/model/type/uri.rb', line 24 def self.serialize(value) return nil if value.nil? return value.to_s if value.is_a?(::URI) value.to_s end |
.valid_uri?(value) ⇒ Boolean
Validate URI format
42 43 44 45 46 47 |
# File 'lib/lutaml/model/type/uri.rb', line 42 def self.valid_uri?(value) ::URI.parse(value.to_s) true rescue ::URI::InvalidURIError false end |