Sha256: 9b0141d7b78587cd62e5bdc4b665586dc068b39bddcf46fb82e18bf3d467d47d

Contents?: true

Size: 1.81 KB

Versions: 17

Compression:

Stored size: 1.81 KB

Contents

module RDF
  ##
  # An RDF term.
  #
  # Terms can be used as subjects, predicates, objects, and contexts of
  # statements.
  #
  # @since 0.3.0
  module Term
    include RDF::Value
    include Comparable

    ##
    # 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`
    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 http://www.w3.org/TR/rdf-sparql-query/#func-RDFterm-equal
    def ==(other)
      super
    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 http://www.w3.org/TR/rdf-sparql-query/#func-sameTerm
    def eql?(other)
      super
    end

    ##
    # Returns `true` if this term is constant.
    #
    # @return [Boolean] `true` or `false`
    # @see    #variable?
    def constant?
      !(variable?)
    end

    ##
    # Returns `true` if this term is variable.
    #
    # @return [Boolean] `true` or `false`
    # @see    #constant?
    def variable?
      false
    end
  end # Term
end # RDF

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rdf-1.0.3 lib/rdf/model/term.rb
rdf-1.0.2 lib/rdf/model/term.rb
rdf-1.0.1 lib/rdf/model/term.rb
rdf-1.0.0 lib/rdf/model/term.rb
rdf-0.3.11.1 lib/rdf/model/term.rb
rdf-0.3.11 lib/rdf/model/term.rb
rdf-0.3.10 lib/rdf/model/term.rb
rdf-0.3.9 lib/rdf/model/term.rb
rdf-0.3.8 lib/rdf/model/term.rb
rdf-0.3.7 lib/rdf/model/term.rb
rdf-0.3.5.2 lib/rdf/model/term.rb
openlogic-rdf-0.3.7 lib/rdf/model/term.rb
openlogic-rdf-0.3.6 lib/rdf/model/term.rb
rdf-0.3.5.1 lib/rdf/model/term.rb
rdf-0.3.5 lib/rdf/model/term.rb
rdf-0.3.4.1 lib/rdf/model/term.rb
rdf-0.3.4 lib/rdf/model/term.rb