Class: RDF::N3::Algebra::Log::N3String
- Inherits:
-
ResourceOperator
- Object
- SPARQL::Algebra::Operator::Binary
- ResourceOperator
- RDF::N3::Algebra::Log::N3String
- Defined in:
- lib/rdf/n3/algebra/log/n3_string.rb
Overview
The subject formula, expressed as N3, gives this string.
Constant Summary collapse
Instance Attribute Summary
Attributes included from Enumerable
Instance Method Summary collapse
-
#resolve(resource, position: :subject) ⇒ RDF::Term
Serializes the subject formula into an N3 string representation.
-
#valid?(subject, object) ⇒ Boolean
Subject must evaluate to a formula and object to a literal.
Methods inherited from ResourceOperator
#as_literal, #execute, #input_operand
Methods included from Builtin
#each, #evaluate, #hash, #input_operand, #rank, #to_uri
Instance Method Details
#resolve(resource, position: :subject) ⇒ RDF::Term
Serializes the subject formula into an N3 string representation.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rdf/n3/algebra/log/n3_string.rb', line 13 def resolve(resource, position: :subject) case position when :subject return nil unless resource.formula? as_literal(RDF::N3::Writer.buffer {|w| resource.each {|st| w << st}}) when :object return nil unless resource.literal? || resource.variable? resource end end |
#valid?(subject, object) ⇒ Boolean
Subject must evaluate to a formula and object to a literal.
30 31 32 |
# File 'lib/rdf/n3/algebra/log/n3_string.rb', line 30 def valid?(subject, object) subject.formula? && (object.variable? || object.literal?) end |