Class: RDF::N3::Algebra::Log::OutputString

Inherits:
ResourceOperator
  • Object
show all
Defined in:
lib/rdf/n3/algebra/log/output_string.rb

Overview

The subject is a key and the object is a string, where the strings are to be output in the order of the keys.

Constant Summary collapse

NAME =
:logOutputString
URI =
RDF::N3::Log.outputString

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Instance Method Summary collapse

Methods inherited from ResourceOperator

#as_literal, #execute, #valid?

Methods included from Builtin

#each, #evaluate, #hash, #rank, #to_uri

Instance Method Details

#apply(term1, term2) ⇒ RDF::Literal::Boolean

Returns ‘term2`, but adds `term2` as an output keyed on `term1`.

Parameters:

Returns:

  • (RDF::Literal::Boolean)

    ‘true` or `false`

Raises:

  • (TypeError)

    if either operand is not an RDF term or operands are not comperable

See Also:

  • Term#==


30
31
32
33
# File 'lib/rdf/n3/algebra/log/output_string.rb', line 30

def apply(term1, term2)
  (@options[:strings][term1.to_s] ||= []) << term2.to_s
  term2
end

#input_operandObject

Both subject and object are inputs.



36
37
38
# File 'lib/rdf/n3/algebra/log/output_string.rb', line 36

def input_operand
  RDF::N3::List.new(values: operands)
end

#resolve(resource, position:) ⇒ RDF::Term

Resolves inputs as strings.

Parameters:

  • resource (RDF::Term)
  • position (:subject, :object)

Returns:

See Also:

  • ResourceOperator#evaluate


15
16
17
# File 'lib/rdf/n3/algebra/log/output_string.rb', line 15

def resolve(resource, position:)
  SPARQL::Algebra::Expression.cast(RDF::XSD.string, resource) if resource.term?
end