Class: RDF::Literal::AnyURI
- Inherits:
-
RDF::Literal
- Object
- RDF::Literal
- RDF::Literal::AnyURI
- Defined in:
- lib/rdf/xsd/any_uri.rb
Overview
anyURI represents a Uniform Resource Identifier Reference (URI). An anyURI value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be a URI Reference). This type should be used to specify the intention that the value fulfills the role of a URI as defined by [RFC 2396], as amended by [RFC 2732].
Constant Summary collapse
- DATATYPE =
RDF::XSD.anyURI
Instance Method Summary collapse
-
#canonicalize! ⇒ RDF::Literal
Converts this literal into its canonical lexical representation.
-
#initialize(value, datatype: nil, lexical: nil, **options) ⇒ AnyURI
constructor
A new instance of AnyURI.
-
#valid? ⇒ Boolean
Returns
true
if the value adheres to the defined grammar of the datatype.
Constructor Details
#initialize(value, datatype: nil, lexical: nil, **options) ⇒ AnyURI
Returns a new instance of AnyURI.
28 29 30 31 32 |
# File 'lib/rdf/xsd/any_uri.rb', line 28 def initialize(value, datatype: nil, lexical: nil, **) super(value, datatype: datatype, lexical: lexical) @object = RDF::URI(value) canonicalize! unless value.is_a?(String) end |
Instance Method Details
#canonicalize! ⇒ RDF::Literal
Converts this literal into its canonical lexical representation.
38 39 40 41 |
# File 'lib/rdf/xsd/any_uri.rb', line 38 def canonicalize! @string = @object.canonicalize self end |
#valid? ⇒ Boolean
Returns true
if the value adheres to the defined grammar of the datatype.
48 49 50 |
# File 'lib/rdf/xsd/any_uri.rb', line 48 def valid? @object.validate! rescue false end |