module RDF::Value
An RDF value.
This is the basis for the RDF.rb class hierarchy. Anything that can be a term of {RDF::Statement RDF statements} should directly or indirectly include this module, but it does not define classes that can be included within a {RDF::Statement}, for this see {RDF::Term}.
@example Checking if a value is a resource (blank node or URI reference)
value.resource?
@example Checking if a value is a blank node
value.node?
@example Checking if a value is a URI reference
value.uri? value.iri?
@example Checking if a value is a literal
value.literal?
@see RDF::Literal @see RDF::Node @see RDF::Resource @see RDF::URI @see RDF::Graph @see RDF::List @see RDF::Statement
Extensions for `RDF::Value`.
Extensions for `RDF::Value`.
Public Instance Methods
Is this value named?
@return [Boolean] `true` or `false`
# File lib/rdf/model/value.rb, line 129 def anonymous? false end
Returns a copy of this value converted into its canonical representation.
@return [RDF::Value] @since 1.0.8
# File lib/rdf/model/value.rb, line 168 def canonicalize self.dup.canonicalize! end
Converts this value into its canonical representation.
Should be overridden by concrete classes.
@return [RDF::Value] `self` @since 1.0.8
# File lib/rdf/model/value.rb, line 179 def canonicalize! self end
Is this constant, or are all of its components constant?
Same as `!variable?`
@return [Boolean] `true` or `false` @see variable?
# File lib/rdf/model/value.rb, line 121 def constant? !(variable?) end
Returns `true` if `self` is a {RDF::Graph}.
@return [Boolean]
# File lib/rdf/model/value.rb, line 35 def graph? false end
Returns a developer-friendly representation of `self`.
The result will be of the format `#<RDF::Value::0x12345678(…)>`, where `…` is the string returned by `#to_s`.
@return [String]
# File lib/rdf/model/value.rb, line 206 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, to_s) end
Outputs a developer-friendly representation of `self` to `stderr`.
@return [void]
# File lib/rdf/model/value.rb, line 214 def inspect! warn(inspect) end
Is this value invalid, or is it composed of any invalid components?
@return [Boolean] `true` or `false` @since 0.2.1
# File lib/rdf/model/value.rb, line 147 def invalid? !valid? end
Is this an {RDF::IRI}?
By default this is simply an alias for {RDF::Value#uri?}.
@return [Boolean]
# File lib/rdf/model/value.rb, line 93 def iri? uri? end
Is this a {RDF::List}?
@return [Boolean]
# File lib/rdf/model/value.rb, line 51 def list? false end
Is this a {RDF::Literal}?
@return [Boolean]
# File lib/rdf/model/value.rb, line 75 def literal? false end
Is this a {RDF::Node}, or does it contain a node?
@return [Boolean]
# File lib/rdf/model/value.rb, line 83 def node? false end
Is this a {RDF::Resource}?
@return [Boolean]
# File lib/rdf/model/value.rb, line 67 def resource? false end
Is this a {RDF::Statement}?
@return [Boolean]
# File lib/rdf/model/value.rb, line 43 def statement? false end
Is this a {RDF::Term}?
@return [Boolean]
# File lib/rdf/model/value.rb, line 59 def term? false end
Returns the N-Quads representation of this value.
This method is only available when the 'rdf/nquads' serializer has been explicitly required.
@return [String] @since 0.4.0
# File lib/rdf/nquads.rb, line 165 def to_nquads RDF::NQuads.serialize(self) end
Returns the N-Triples representation of this value.
This method is only available when the 'rdf/ntriples' serializer has been explicitly required.
@return [String] @since 0.2.1
# File lib/rdf/ntriples.rb, line 98 def to_ntriples RDF::NTriples.serialize(self) end
Returns an `RDF::Value` representation of `self`.
@return [RDF::Value]
# File lib/rdf/model/value.rb, line 187 def to_rdf self end
Returns an `RDF::Term` representation of `self`.
@return [RDF::Value]
# File lib/rdf/model/value.rb, line 195 def to_term raise NotImplementedError, "#{self.class}#read_triple" # override in subclasses end
Default implementation of `type_error`, which returns false. Classes including RDF::TypeCheck will raise TypeError instead.
@return [false]
# File lib/rdf/model/value.rb, line 224 def type_error(message) false end
Is this an {RDF::URI}?
@return [Boolean]
# File lib/rdf/model/value.rb, line 101 def uri? false end
Is this value valid, and composed only of valid components?
@return [Boolean] `true` or `false` @since 0.3.9
# File lib/rdf/model/value.rb, line 138 def valid? true end
Default validate! implementation, overridden in concrete classes @return [RDF::Value] `self` @raise [ArgumentError] if the value is invalid @since 0.3.9
# File lib/rdf/model/value.rb, line 156 def validate! raise ArgumentError, "#{self.inspect} is not valid" if invalid? self end
Is this a {RDF::Query::Variable}, or does it contain a variable?
@return [Boolean] @since 0.1.7
# File lib/rdf/model/value.rb, line 110 def variable? false end