Sha256: 2a69900e2d49dc0d79c77768d6f454c903f949311e608ea65045bd1988efd57d
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
module RDF::N3::Algebra::Str # The subject is a list of two strings. The second string is a regular expression in the perl, python style. It must contain one group (a part in parentheses). If the first string in the list matches the regular expression, then the object is calculated as being the part of the first string which matches the group. # # @example # ("abcdef" "ab(..)ef") string:scrape "cd" class Scrape < RDF::N3::Algebra::ListOperator include RDF::N3::Algebra::Builtin NAME = :strScrape URI = RDF::N3::Str.scrape ## # @param [RDF::N3::List] list # @return [RDF::Term] # @see RDF::N3::ListOperator#evaluate def resolve(list) input, regex = list.to_a md = Regexp.new(regex.to_s).match(input.to_s) RDF::Literal(md[1]) if md end ## # Subclasses may override or supplement validate to perform validation on the list subject # # @param [RDF::N3::List] list # @return [Boolean] def validate(list) if super && list.length == 2 true else log_error(NAME) {"list must have exactly two entries: #{list.to_sxp}"} false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rdf-n3-3.3.0 | lib/rdf/n3/algebra/str/scrape.rb |
rdf-n3-3.2.1 | lib/rdf/n3/algebra/str/scrape.rb |
rdf-n3-3.2.0 | lib/rdf/n3/algebra/str/scrape.rb |
rdf-n3-3.1.2 | lib/rdf/n3/algebra/str/scrape.rb |