Class: RDF::Statement

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/extensions.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/json-ld-d4556f730a9b/lib/json/ld/extensions.rb,
vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb

Constant Summary collapse

@@entailments =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_entailment(method, proc) ⇒ Object

Add an entailment method. The method accepts no arguments, and returns or yields an array of values associated with the particular entailment method

Parameters:



123
124
125
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/extensions.rb', line 123

def add_entailment(method, proc)
  @@entailments[method] = proc
end

Instance Method Details

#entail(method) {|term| ... } ⇒ Array<Term>

Perform an entailment on this term.

Parameters:

  • method (Symbol)

    A registered entailment method

Yields:

  • term

Yield Parameters:

Returns:



135
136
137
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/extensions.rb', line 135

def entail(method, &block)
  self.send(@@entailments.fetch(method), &block)
end

#to_sxp_binArray

Transform Statement Pattern into an SXP

Returns:



267
268
269
270
271
272
273
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/sparql-7b34b4cf091a/lib/sparql/algebra/extensions.rb', line 267

def to_sxp_bin
  if has_graph?
    [:quad, subject, predicate, object, graph_name]
  else
    [:triple, subject, predicate, object]
  end
end

#valid_extended?Boolean

Validate extended RDF

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/json-ld-d4556f730a9b/lib/json/ld/extensions.rb', line 13

def valid_extended?
  has_subject?    && subject.resource? && subject.valid_extended? &&
  has_predicate?  && predicate.resource? && predicate.valid_extended? &&
  has_object?     && object.term? && object.valid_extended? &&
  (has_graph?      ? (graph_name.resource? && graph_name.valid_extended?) : true)
end