Class: SPARQL::Algebra::Operator::LangMatches
- Inherits:
-
Binary
- Object
- SPARQL::Algebra::Operator
- Binary
- SPARQL::Algebra::Operator::LangMatches
- Includes:
- Evaluatable
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/lang_matches.rb
Overview
The SPARQL langMatches
operator.
[121] BuiltInCall ::= ... | 'LANGMATCHES' '(' Expression ',' Expression ')'
Constant Summary collapse
- NAME =
:langMatches
Constants inherited from Binary
Constants inherited from SPARQL::Algebra::Operator
Constants included from Expression
Constants included from RDF::Util::Logger
Instance Attribute Summary
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse
-
#apply(language_tag, language_range, **options) ⇒ RDF::Literal::Boolean
Returns
true
if the language tag (the first operand) matches the language range (the second operand). -
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
Methods included from Evaluatable
#evaluate, #memoize, #replace_aggregate!, #replace_vars!
Methods inherited from Binary
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, base_uri, #base_uri, base_uri=, #bind, #boolean, #constant?, #deep_dup, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #formulae, #initialize, #inspect, #mergable?, #ndvars, #node?, #operand, #optimize, #optimize!, #parent, #parent=, #prefixes, prefixes, prefixes=, #rewrite, #to_binary, to_sparql, #to_sxp, #to_sxp_bin, #validate!, #variable?, #variables, #vars
Methods included from Expression
cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Methods included from RDF::Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Binary
Instance Method Details
#apply(language_tag, language_range, **options) ⇒ RDF::Literal::Boolean
Returns true
if the language tag (the first operand) matches the
language range (the second operand).
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/lang_matches.rb', line 38 def apply(language_tag, language_range, **) raise TypeError, "expected a plain RDF::Literal for language_tag, but got #{language_tag.inspect}" unless language_tag.is_a?(RDF::Literal) && language_tag.simple? language_tag = language_tag.to_s.downcase raise TypeError, "expected a plain RDF::Literal for language_range, but got #{language_range.inspect}" unless language_range.is_a?(RDF::Literal) && language_range.simple? language_range = language_range.to_s.downcase case # A language range of "*" matches any non-empty language tag. when language_range.eql?('*') RDF::Literal(!(language_tag.empty?)) # A language range matches a particular language tag if, in a # case-insensitive comparison, it exactly equals the tag, ... when language_tag.eql?(language_range) RDF::Literal::TRUE # ... or if it exactly equals a prefix of the tag such that the # first character following the prefix is "-". else RDF::Literal(language_tag.start_with?(language_range + '-')) end end |
#to_sparql(**options) ⇒ String
Returns a partial SPARQL grammar for this operator.
65 66 67 68 69 70 71 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-796d3be4aa08/lib/sparql/algebra/operator/lang_matches.rb', line 65 def to_sparql(**) "langMatches(" + operands.first.to_sparql(**) + ", " + operands.last.to_sparql(**) + ")" end |