Class: N::Namespace
- Defined in:
- lib/semantic_naming/namespace.rb,
lib/semantic_naming/default_namespaces.rb
Overview
This is for URIs that act as namespaces. A namespace is a “prefix” for URIs.
Shortcuts for some default namespaces are automatically defined (rdf, owl, …). See default_namespaces.rb for details.
Usually there should be no need to change those default namespaces
Constant Summary collapse
- @@default_namespaces =
{ 'rdf' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 'xsd' => "http://www.w3.org/2001/XMLSchema#", 'rdfs' => "http://www.w3.org/2000/01/rdf-schema#", 'owl' => "http://www.w3.org/2002/07/owl#" }
Instance Method Summary collapse
-
#elements_with_type(type, element_type = N::URI) ⇒ Object
Finds all members of the given type that are part of this namespace.
-
#predicates ⇒ Object
Returns a list of predicate names.
Methods inherited from URI
#+, #==, [], #const_missing, #domain_of?, #domain_part, #eql?, from_encoded, #hash, #initialize, is_uri?, #local?, #local_name, make_uri, #method_missing, #my_shortcut, #namespace, #rdf_label, #remote?, #safe_encoded, shortcut, shortcut_exists?, shortcuts, #to_name_s, #to_s, #to_uri, #to_yaml
Constructor Details
This class inherits a constructor from N::URI
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class N::URI
Instance Method Details
#elements_with_type(type, element_type = N::URI) ⇒ Object
Finds all members of the given type that are part of this namespace. Attention: Due to the workings of SPARQL this will retrieve all elements that match the type and filter them. Thus it’s advised to use this only for types of which only a few elements are known to exist (e.g. Onotology classes)
20 21 22 23 24 25 26 |
# File 'lib/semantic_naming/namespace.rb', line 20 def elements_with_type(type, element_type = N::URI) return unless(rdf_active? && is_iri?) qry = ActiveRDF::Query.new(element_type).distinct.select(:s) qry.where(:s, RDF.type, type) qry.regexp(:s, "^#{@uri_s}") qry.execute end |