Class: LD::Patch::Algebra::Index
- Inherits:
-
SPARQL::Algebra::Operator::Unary
- Object
- SPARQL::Algebra::Operator::Unary
- LD::Patch::Algebra::Index
- Includes:
- SPARQL::Algebra::Query
- Defined in:
- lib/ld/patch/algebra/index.rb
Overview
The LD Patch index
operator.
Presuming that the input term identifies an rdf:List, returns the list element indexted by the single operand, or an empty solution set
Constant Summary collapse
- NAME =
:index
Instance Method Summary collapse
-
#execute(queryable, options = {}) ⇒ RDF::Query::Solutions
Executes this upate on the given
writable
graph or repository.
Instance Method Details
#execute(queryable, options = {}) ⇒ RDF::Query::Solutions
Executes this upate on the given writable
graph or repository.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ld/patch/algebra/index.rb', line 21 def execute(queryable, = {}) debug() {"Index"} terms = Array(.fetch(:terms)) index = operand(0) results = terms.map do |term| list = RDF::List.new(subject: term, graph: queryable) list.at(index.to_i) end.flatten RDF::Query::Solutions.new(results.map {|t| RDF::Query::Solution.new(path: t)}) end |