class RDF::N3::Algebra::Str::Scrape
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"
Constants
- NAME
- URI
Public Instance Methods
resolve(list)
click to toggle source
@param [RDF::N3::List] list @return [RDF::Term] @see RDF::N3::ListOperator#evaluate
# File lib/rdf/n3/algebra/str/scrape.rb, line 15 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
validate(list)
click to toggle source
Subclasses may override or supplement validate to perform validation on the list subject
@param [RDF::N3::List] list @return [Boolean]
Calls superclass method
RDF::N3::Algebra::ListOperator#validate
# File lib/rdf/n3/algebra/str/scrape.rb, line 26 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