Class: RDF::N3::Algebra::Str::Contains

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

Overview

True iff the subject string contains the object string.

Constant Summary collapse

NAME =
:strContains
URI =
RDF::N3::Str.contains

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(left, right) ⇒ RDF::Literal::Boolean

Parameters:

  • left (String)

    a literal

  • right (String)

    a literal

Returns:

  • (RDF::Literal::Boolean)


29
30
31
# File 'lib/rdf/n3/algebra/str/contains.rb', line 29

def apply(left, right)
  RDF::Literal(left.to_s.include?(right.to_s)) 
end

#input_operandObject

Neither subect nor object are considered inputs, and must be resolved before evaluation.



19
20
21
# File 'lib/rdf/n3/algebra/str/contains.rb', line 19

def input_operand
  RDF::N3::List.new
end

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

Resolves inputs as strings.

Parameters:

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

Returns:

See Also:

  • ResourceOperator#evaluate


14
15
16
# File 'lib/rdf/n3/algebra/str/contains.rb', line 14

def resolve(resource, position:)
  resource if resource.term?
end