class RDF::Query::Variable

Extensions for `RDF::Query::Variable`.

Public Instance Methods

evaluate(bindings, **options) click to toggle source

Returns the value of this variable in the given `bindings`.

@param [RDF::Query::Solution] bindings

a query solution containing zero or more variable bindings

@param [Hash{Symbol => Object}] options ({})

options passed from query

@return [RDF::Term] the value of this variable @raise [TypeError] if the variable is not bound

# File lib/sparql/algebra/extensions.rb, line 519
def evaluate(bindings, **options)
  raise TypeError if bindings.respond_to?(:bound?) && !bindings.bound?(self)
  bindings[name.to_sym]
end
optimize(**options) click to toggle source

Return self

@return [RDF::Query::Variable] a copy of `self` @see SPARQL::Algebra::Expression#optimize

# File lib/sparql/algebra/extensions.rb, line 529
def optimize(**options)
  self
end
to_sxp() click to toggle source

Display variable as SXP @return [Array]

# File lib/sparql/algebra/extensions.rb, line 535
def to_sxp
  prefix = distinguished? ? (existential? ? '$' : '?') : (existential? ? '$$' : '??')
  unbound? ? "#{prefix}#{name}".to_sym.to_sxp : ["#{prefix}#{name}".to_sym, value].to_sxp
end