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

<=>(other) click to toggle source

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
==(other) click to toggle source

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

Calls superclass method
# File lib/rdf/model/term.rb, line 39
def ==(other)
  super
end
compatible?(other) click to toggle source

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 88
def compatible?(other)
  false
end
eql?(other) click to toggle source

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

Calls superclass method
# File lib/rdf/model/term.rb, line 55
def eql?(other)
  super
end
term?() click to toggle source

Returns `true` if `self` is a {RDF::Term}.

@return [Boolean]

# File lib/rdf/model/term.rb, line 63
def term?
  true
end
to_base() click to toggle source

Returns the base representation of this term.

@return [Sring]

# File lib/rdf/model/term.rb, line 79
def to_base
  RDF::NTriples.serialize(self).freeze
end
to_term() click to toggle source

Returns itself.

@return [RDF::Value]

# File lib/rdf/model/term.rb, line 71
def to_term
  self
end

Protected Instance Methods

escape(string) click to toggle source

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 98
def escape(string)
  raise NotImplementedError, "#{self.class}#escape"
end