Class: RDF::N3::Algebra::Log::ParsedAsN3
- Inherits:
-
ResourceOperator
- Object
- SPARQL::Algebra::Operator::Binary
- ResourceOperator
- RDF::N3::Algebra::Log::ParsedAsN3
- Defined in:
- lib/rdf/n3/algebra/log/parsed_as_n3.rb
Overview
The subject string, parsed as N3, gives this formula.
Constant Summary collapse
Instance Attribute Summary
Attributes included from Enumerable
Instance Method Summary collapse
-
#resolve(resource, position: :subject) ⇒ RDF::Term
Parses the subject into a new formula.
Methods inherited from ResourceOperator
#as_literal, #execute, #input_operand, #valid?
Methods included from Builtin
#each, #evaluate, #hash, #input_operand, #rank, #to_uri
Instance Method Details
#resolve(resource, position: :subject) ⇒ RDF::Term
Parses the subject into a new formula.
Returns nil if resource does not validate, given its position
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rdf/n3/algebra/log/parsed_as_n3.rb', line 15 def resolve(resource, position: :subject) case position when :subject return nil unless resource.literal? begin repo = RDF::N3::Repository.new repo << RDF::N3::Reader.new(resource.to_s, **@options.merge(list_terms: true, logger: false)) log_debug("logParsedAsN3") {SXP::Generator.string repo.statements.to_sxp_bin} content_hash = resource.hash # used as name of resulting formula form = RDF::N3::Algebra::Formula.from_enumerable(repo, graph_name: RDF::Node.intern(content_hash)) log_info(NAME) {"form hash (#{resource}): #{form.hash}"} form rescue RDF::ReaderError nil end when :object return nil unless resource.literal? || resource.is_a?(RDF::Query::Variable) resource end end |