Module: RDF::Term

Includes:
Comparable, Value
Included in:
Literal, Query::Variable, Resource
Defined in:
lib/rdf/model/term.rb

Overview

An RDF term.

Terms can be used as subjects, predicates, objects, and contexts of statements.

Since:

  • 0.3.0

Instance Method Summary collapse

Methods included from Value

#graph?, #inspect, #inspect!, #iri?, #literal?, #node?, #resource?, #statement?, #to_ntriples, #to_quad, #to_rdf, #type_error, #uri?

Instance Method Details

#<=>(other) ⇒ Integer

This method is abstract.

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`.

Parameters:

  • other (Object)

Returns:

  • (Integer)

    ‘-1`, `0`, or `1`

Since:

  • 0.3.0



23
24
25
# File 'lib/rdf/model/term.rb', line 23

def <=>(other)
  self.to_s <=> other.to_s
end

#==(other) ⇒ Integer

This method is abstract.

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`.

Parameters:

  • other (Object)

Returns:

  • (Integer)

    ‘-1`, `0`, or `1`

See Also:

Since:

  • 0.3.0



39
40
41
# File 'lib/rdf/model/term.rb', line 39

def ==(other)
  super
end

#constant?Boolean

Returns ‘true` if this term is constant.

Returns:

  • (Boolean)

    ‘true` or `false`

See Also:

Since:

  • 0.3.0



64
65
66
# File 'lib/rdf/model/term.rb', line 64

def constant?
  !(variable?)
end

#eql?(other) ⇒ Integer

This method is abstract.

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`.

Parameters:

  • other (Object)

Returns:

  • (Integer)

    ‘-1`, `0`, or `1`

See Also:

Since:

  • 0.3.0



55
56
57
# File 'lib/rdf/model/term.rb', line 55

def eql?(other)
  super
end

#variable?Boolean

Returns ‘true` if this term is variable.

Returns:

  • (Boolean)

    ‘true` or `false`

See Also:

Since:

  • 0.3.0



73
74
75
# File 'lib/rdf/model/term.rb', line 73

def variable?
  false
end