Sha256: d7c6982c6b3ecd432947611f3aa8e2eca5cc83852732bb59f034a1a2ab30c894
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
module RDF::N3::Algebra::Str # 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. class Matches < RDF::N3::Algebra::ResourceOperator NAME = :strMatches URI = RDF::N3::Str.matches ## # Resolves inputs as strings. # # @param [RDF::Term] resource # @param [:subject, :object] position # @return [RDF::Literal] # @see RDF::N3::ResourceOperator#evaluate def resolve(resource, position:) resource if resource.literal? end # Neither subect nor object are considered inputs, and must be resolved before evaluation. def input_operand RDF::N3::List.new end ## # Tre if right, treated as a regular expression, matches left # # @param [RDF::Literal] left # a simple literal # @param [RDF::Literal] right # a simple literal # @return [RDF::Literal::Boolean] `true` or `false` # @see https://www.w3.org/TR/xpath-functions/#regex-syntax def apply(left, right) RDF::Literal(Regexp.new(right.to_s).match?(left.to_s)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems