Class: RDF::Node
- Inherits:
-
Object
- Object
- RDF::Node
- 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
-
#domain_compatible?(resource, queryable, options = {}) ⇒ Boolean
Determine if the domain of a property term is consistent with the specified resource in ‘queryable`.
-
#entail(method) {|term| ... } ⇒ Array<Term>
Perform an entailment on this term.
-
#range_compatible?(resource, queryable, options = {}) ⇒ Boolean
Determine if the range of a property term is consistent with the specified resource in ‘queryable`.
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
68 69 70 |
# File 'lib/rdf/reasoner/extensions.rb', line 68 def add_entailment(method, proc) @@entailments[method] = proc end |
Instance Method Details
#domain_compatible?(resource, queryable, options = {}) ⇒ Boolean
Determine if the domain of a property term is consistent with the specified resource in ‘queryable`.
92 93 94 95 96 |
# File 'lib/rdf/reasoner/extensions.rb', line 92 def domain_compatible?(resource, queryable, = {}) %w(owl rdfs schema).map {|r| "domain_compatible_#{r}?".to_sym}.all? do |meth| !self.respond_to?(meth) || self.send(meth, resource, queryable, **) end end |
#entail(method) {|term| ... } ⇒ Array<Term>
Perform an entailment on this term.
80 81 82 |
# File 'lib/rdf/reasoner/extensions.rb', line 80 def entail(method, &block) self.send(@@entailments.fetch(method), &block) end |
#range_compatible?(resource, queryable, options = {}) ⇒ Boolean
Determine if the range of a property term is consistent with the specified resource in ‘queryable`.
Specific entailment regimes should insert themselves before this to apply the appropriate semantic condition
108 109 110 111 112 |
# File 'lib/rdf/reasoner/extensions.rb', line 108 def range_compatible?(resource, queryable, = {}) %w(owl rdfs schema).map {|r| "range_compatible_#{r}?".to_sym}.all? do |meth| !self.respond_to?(meth) || self.send(meth, resource, queryable, ) end end |