Class: RDF::Query::Variable

Inherits:
Object show all
Includes:
SPARQL::Algebra::Expression
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb

Overview

Extensions for RDF::Query::Variable.

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?

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}) (defaults to: {})

    ({}) options passed from query

Returns:

Raises:

  • (TypeError)

    if the variable is not bound



389
390
391
392
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 389

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

#to_sObject



394
395
396
397
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 394

def to_s
  prefix = distinguished? || name.to_s[0,1] == '.' ? '?' : "??"
  unbound? ? "#{prefix}#{name}" : "#{prefix}#{name}=#{value}"
end