Class: Jena::Vocab::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/jena_jruby/namespace.rb

Overview

A namespace is an object for resolving identifiers in scope denoted by a base URI to a full URI. For example,

rdfs = Namespace.new( "http://www.w3.org/2000/01/rdf-schema#" )
rdfs.comment # => "http://www.w3.org/2000/01/rdf-schema#comment"

There is no checking that the resolved name is known in the defined namespace (e.g. rdfs.commnet will work without a warning)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ns) ⇒ Namespace

Initialize this namespace with the given root URI. E.g, for RDFS, this would be

rdfs = Namespace.new( "http://www.w3.org/2000/01/rdf-schema#" )


18
19
20
# File 'lib/jena_jruby/namespace.rb', line 18

def initialize( ns )
  @ns = ns
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



24
25
26
27
28
# File 'lib/jena_jruby/namespace.rb', line 24

def method_missing( name, *args)
  prop = !args.empty? && args.first
  n = "#{@ns}#{name}"
  prop ? Jena::Core::ResourceFactory.createProperty(n) : Jena::Core::ResourceFactory.createResource(n)
end

Instance Attribute Details

#nsObject (readonly)

Returns the value of attribute ns.



13
14
15
# File 'lib/jena_jruby/namespace.rb', line 13

def ns
  @ns
end