Module: RDF::Mutable

Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/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:



194
195
196
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/extensions.rb', line 194

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

Instance Method Details

#entail(*rules, &block) ⇒ RDF::Mutable

Return a new mutable, composed of original and entailed statements

Parameters:

  • rules (Array<Symbol>)

    Registered entailment method(s)

Returns:

See Also:

  • RDF::Mutable.[RDF[RDF::Enumerable[RDF::Enumerable#entail]


204
205
206
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/extensions.rb', line 204

def entail(*rules, &block)
  self.dup.entail!(*rules)
end

#entail!(*rules, &block) ⇒ RDF::Mutable

Add entailed statements to the mutable

Parameters:

  • rules (Array<Symbol>)

    Registered entailment method(s)

Returns:

See Also:

  • RDF::Mutable.[RDF[RDF::Enumerable[RDF::Enumerable#entail]


213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-reasoner-63fee6d2320c/lib/rdf/reasoner/extensions.rb', line 213

def entail!(*rules, &block)
  rules = %w(subClassOf subPropertyOf domain range).map(&:to_sym) if rules.empty?
  statements = []

  self.each do |statement|
    rules.each do |rule|
      statement.entail(rule) do |st|
        statements << st
      end
    end
  end
  self.insert(*statements)
  self
end