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 106
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?(*args) click to toggle source

@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
terms() click to toggle source

Returns an array including just itself.

@return [Array<RDF::Value>]

# File lib/rdf/model/term.rb, line 89
def terms
  [self]
end
to_base() click to toggle source

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

Returns itself.

@return [RDF::Value]

# File lib/rdf/model/term.rb, line 81
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 116
def escape(string)
  raise NotImplementedError, "#{self.class}#escape"
end