Module: RDF::Mutable
- Defined in:
- lib/rdf/reasoner/extensions.rb
Constant Summary collapse
- @@entailments =
{}
Class Method Summary collapse
-
.add_entailment(method, proc) ⇒ Object
Add an entailment method.
Instance Method Summary collapse
-
#entail(*rules, &block) ⇒ RDF::Mutable
Return a new mutable, composed of original and entailed statements.
-
#entail!(*rules, &block) ⇒ RDF::Mutable
Add entailed statements to the mutable.
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
194 195 196 |
# File '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
204 205 206 |
# File '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
213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File '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 |