Class: RDF::N3::Algebra::Str::StartsWith

Inherits:
SPARQL::Algebra::Operator::Binary show all
Includes:
Enumerable, Util::Logger, SPARQL::Algebra::Query, SPARQL::Algebra::Update
Defined in:
vendor/bundler/ruby/2.6.0/bundler/gems/rdf-n3-015ce184efe3/lib/rdf/n3/algebra/str/startsWith.rb

Overview

True iff the subject string starts with the object string.

Constant Summary collapse

NAME =
:strStartsWith

Constants included from Util::Logger

Util::Logger::IOWrapper

Constants inherited from SPARQL::Algebra::Operator::Binary

SPARQL::Algebra::Operator::Binary::ARITY

Constants inherited from SPARQL::Algebra::Operator

SPARQL::Algebra::Operator::ARITY, SPARQL::Algebra::Operator::IsURI, SPARQL::Algebra::Operator::URI

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Attributes included from SPARQL::Algebra::Query

#solutions

Attributes inherited from SPARQL::Algebra::Operator

#operands

Instance Method Summary collapse

Methods included from Util::Logger

#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger

Methods included from Enumerable

add_entailment, #contain?, #dump, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph_names, #has_graph?, #has_object?, #has_predicate?, #has_quad?, #has_statement?, #has_subject?, #has_term?, #has_triple?, #invalid?, #method_missing, #objects, #predicates, #project_graph, #quads, #respond_to_missing?, #statements, #subjects, #supports?, #terms, #to_a, #to_h, #to_set, #triples, #valid?, #validate!

Methods included from Util::Aliasing::LateBound

#alias_method

Methods included from Countable

#count, #empty?

Methods included from Isomorphic

#bijection_to, #isomorphic_with?

Methods included from SPARQL::Algebra::Update

#graph_name=, #unshift, #variables

Methods included from SPARQL::Algebra::Query

#each_solution, #empty?, #failed?, #graph_name=, #matched?, #query_yields_boolean?, #query_yields_solutions?, #query_yields_statements?, #unshift, #variables

Methods inherited from SPARQL::Algebra::Operator::Binary

#initialize

Methods inherited from SPARQL::Algebra::Operator

#aggregate?, arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, #to_sxp, #to_sxp_bin, #validate!, #variable?, #vars

Methods included from SPARQL::Algebra::Expression

cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?

Constructor Details

This class inherits a constructor from SPARQL::Algebra::Operator::Binary

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RDF::Enumerable

Instance Method Details

#each {|statement| ... } ⇒ Object

Does not yield statements.

Yields:

  • (statement)

    each matching statement

Yield Parameters:

Yield Returns:

  • (void)

    ignored



49
50
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdf-n3-015ce184efe3/lib/rdf/n3/algebra/str/startsWith.rb', line 49

def each(&block)
end

#execute(queryable, solutions:, **options) ⇒ RDF::Query::Solutions

The string:startsWith operator corresponds to the XPath fn:starts-with function. The arguments must be argument compatible otherwise an error is raised.

For constant inputs that evaulate to true, the original solutions are returned.

For constant inputs that evaluate to false, the empty solution set is returned. XXX

Otherwise, for variable operands, it binds matching variables to the solution set.

Parameters:

Returns:

Raises:

  • (TypeError)

    if operands are not compatible



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdf-n3-015ce184efe3/lib/rdf/n3/algebra/str/startsWith.rb', line 25

def execute(queryable, solutions:, **options)
  log_debug {"strStartsWith #{operands.to_sxp}"}
  @solutions = solutions.filter do |solution|
    left, right = operands.map {|op| op.evaluate(solution.bindings)}
    if !left.compatible?(right)
      log_debug {"(strStartsWith incompatible operands #{[left, right].to_sxp})"}
      false
    elsif !left.to_s.start_with?(right.to_s)
      log_debug {"(strStartsWith false #{[left, right].to_sxp})"}
      false
    else
      log_debug {"(strStartsWith true #{[left, right].to_sxp})"}
      true
    end
  end
end

#graph_nameRDF::Resource

Graph name associated with this operation, using the name of the parent

Returns:



54
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdf-n3-015ce184efe3/lib/rdf/n3/algebra/str/startsWith.rb', line 54

def graph_name; parent.graph_name; end