module RDF::Term
An RDF
term.
Terms can be used as subjects, predicates, objects, and graph names of statements.
@since 0.3.0
Public Instance Methods
Compares ‘self` to `other` for sorting purposes.
Subclasses should override this to provide a more meaningful implementation than the default which simply performs a string comparison based on ‘#to_s`.
@abstract @param [Object] other @return [Integer] ‘-1`, `0`, or `1`
# File lib/rdf/model/term.rb, line 23 def <=>(other) self.to_s <=> other.to_s end
Compares ‘self` to `other` to implement RDFterm-equal.
Subclasses should override this to provide a more meaningful implementation than the default which simply performs a string comparison based on ‘#to_s`.
@abstract @param [Object] other @return [Integer] ‘-1`, `0`, or `1`
@see www.w3.org/TR/rdf-sparql-query/#func-RDFterm-equal
# File lib/rdf/model/term.rb, line 39 def ==(other) super end
Term
compatibility according to SPARQL
@see www.w3.org/TR/sparql11-query/#func-arg-compatibility @since 2.0
# File lib/rdf/model/term.rb, line 106 def compatible?(other) false end
Determins if ‘self` is the same term as `other`.
Subclasses should override this to provide a more meaningful implementation than the default which simply performs a string comparison based on ‘#to_s`.
@abstract @param [Object] other @return [Integer] ‘-1`, `0`, or `1`
@see www.w3.org/TR/rdf-sparql-query/#func-sameTerm
# File lib/rdf/model/term.rb, line 55 def eql?(other) super end
@overload term?
Returns `true` if `self` is a {RDF::Term}. @return [Boolean]
@overload term?(name)
Returns `true` if `self` contains the given RDF subject term. @param [RDF::Resource] value @return [Boolean]
# File lib/rdf/model/term.rb, line 69 def term?(*args) case args.length when 0 then true when 1 then false else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)") end end
Returns an array including just itself.
@return [Array<RDF::Value>]
# File lib/rdf/model/term.rb, line 89 def terms [self] end
Returns the base representation of this term.
@return [Sring]
# File lib/rdf/model/term.rb, line 97 def to_base RDF::NTriples.serialize(self).freeze end
Returns itself.
@return [RDF::Value]
# File lib/rdf/model/term.rb, line 81 def to_term self end
Protected Instance Methods
Escape a term using escapes. This should be implemented as appropriate for the given type of term.
@param [String] string @return [String]
# File lib/rdf/model/term.rb, line 116 def escape(string) raise NotImplementedError, "#{self.class}#escape" end