Module: RDF::Term

Includes:
Comparable, Value, SPARQL::Algebra::Expression
Included in:
Literal, Query::Variable, Resource
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/extensions.rb

Overview

Extensions for RDF::Term.

Instance Method Summary collapse

Methods included from SPARQL::Algebra::Expression

cast, #constant?, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Methods included from Value

#anonymous?, #canonicalize, #canonicalize!, #constant?, #graph?, #inspect, #inspect!, #invalid?, #iri?, #list?, #literal?, #node?, #resource?, #start_with?, #statement?, #to_nquads, #to_ntriples, #to_rdf, #type_error, #uri?, #valid?, #validate!, #variable?

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:

Returns:

Since:

  • 0.3.0



23
24
25
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/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:

Returns:

See Also:

Since:

  • 0.3.0



39
40
41
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 39

def ==(other)
  super
end

#aggregate?Boolean

Returns:

  • (Boolean)


198
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/extensions.rb', line 198

def aggregate?; false; end

#compatible?(other) ⇒ Boolean

Term compatibility according to SPARQL

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0



88
89
90
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 88

def compatible?(other)
  false
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:

Returns:

See Also:

Since:

  • 0.3.0



55
56
57
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 55

def eql?(other)
  super
end

#escape(string) ⇒ String (protected)

Escape a term using escapes. This should be implemented as appropriate for the given type of term.

Parameters:

Returns:

Raises:

  • (NotImplementedError)

Since:

  • 0.3.0



98
99
100
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 98

def escape(string)
  raise NotImplementedError, "#{self.class}#escape"
end

#evaluate(bindings, options = {}) ⇒ RDF::Term

Parameters:

  • bindings (RDF::Query::Solution)

    a query solution containing zero or more variable bindings

  • options (Hash{Symbol => Object}) (defaults to: {})

    ({}) options passed from query

Returns:



194
195
196
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/extensions.rb', line 194

def evaluate(bindings, options = {})
  self
end

#ndvarsArray<RDF::Query::Variable>

Return the non-destinguished variables contained within this operator



203
204
205
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/extensions.rb', line 203

def ndvars
  vars.reject(&:distinguished?)
end

#term?Boolean

Returns true if self is a RDF::Term.

Returns:

  • (Boolean)

Since:

  • 0.3.0



63
64
65
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 63

def term?
  true
end

#to_baseSring

Returns the base representation of this term.

Returns:

  • (Sring)

Since:

  • 0.3.0



79
80
81
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 79

def to_base
  RDF::NTriples.serialize(self).freeze
end

#to_termRDF::Value

Returns itself.

Returns:

Since:

  • 0.3.0



71
72
73
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-491e9bb5b443/lib/rdf/model/term.rb', line 71

def to_term
  self
end

#varsArray<RDF::Query::Variable>

Return the variables contained within this operator



210
211
212
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-b66c70fb77a0/lib/sparql/algebra/extensions.rb', line 210

def vars
  variable? ? [self] : []
end