Class: RDF::N3::Algebra::Str::Matches
- Inherits:
-
ResourceOperator
- Object
- SPARQL::Algebra::Operator::Binary
- ResourceOperator
- RDF::N3::Algebra::Str::Matches
- Defined in:
- lib/rdf/n3/algebra/str/matches.rb
Overview
The subject is a string; the object is is a regular expression in the perl, python style. It is true iff the string matches the regexp.
Direct Known Subclasses
Constant Summary collapse
Instance Attribute Summary
Attributes included from Enumerable
Instance Method Summary collapse
-
#apply(left, right) ⇒ RDF::Literal::Boolean
Tre if right, treated as a regular expression, matches left.
-
#input_operand ⇒ Object
Neither subect nor object are considered inputs, and must be resolved before evaluation.
-
#resolve(resource, position:) ⇒ RDF::Literal
Resolves inputs as strings.
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
Tre if right, treated as a regular expression, matches left
33 34 35 |
# File 'lib/rdf/n3/algebra/str/matches.rb', line 33 def apply(left, right) RDF::Literal(Regexp.new(right.to_s).match?(left.to_s)) end |
#input_operand ⇒ Object
Neither subect nor object are considered inputs, and must be resolved before evaluation.
20 21 22 |
# File 'lib/rdf/n3/algebra/str/matches.rb', line 20 def input_operand RDF::N3::List.new end |
#resolve(resource, position:) ⇒ RDF::Literal
Resolves inputs as strings.
15 16 17 |
# File 'lib/rdf/n3/algebra/str/matches.rb', line 15 def resolve(resource, position:) resource if resource.literal? end |