Class: RDF::Query::Variable

Inherits:
Object show all
Includes:
SPARQL::Algebra::Expression
Defined in:
lib/sparql/algebra/extensions.rb

Overview

Extensions for RDF::Query::Variable.

Constant Summary

Constants included from SPARQL::Algebra::Expression

SPARQL::Algebra::Expression::PATTERN_PARENTS

Instance Method Summary collapse

Methods included from SPARQL::Algebra::Expression

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

Instance Method Details

#evaluate(bindings, **options) ⇒ RDF::Term

Returns the value of this variable in the given bindings.

Parameters:

  • bindings (RDF::Query::Solution)

    a query solution containing zero or more variable bindings

  • options (Hash{Symbol => Object})

    ({}) options passed from query

Returns:

Raises:

  • (TypeError)

    if the variable is not bound



571
572
573
574
# File 'lib/sparql/algebra/extensions.rb', line 571

def evaluate(bindings, **options)
  raise TypeError if bindings.respond_to?(:bound?) && !bindings.bound?(self)
  bindings[name.to_sym]
end

#optimize(**options) ⇒ RDF::Query::Variable

Return self

Returns:

See Also:



581
582
583
# File 'lib/sparql/algebra/extensions.rb', line 581

def optimize(**options)
  self
end

#to_sparql(**options) ⇒ String

Returns a partial SPARQL grammar for this term.

The Non-distinguished form (??xxx) is not part of the grammar, so replace with a blank-node

Returns:

  • (String)


592
593
594
# File 'lib/sparql/algebra/extensions.rb', line 592

def to_sparql(**options)
  self.distinguished? ? super : "_:_nd#{self.name}"
end