Module: NS

Defined in:
lib/xml_schema/ns.rb

Class Method Summary collapse

Class Method Details

.add(name, uri) ⇒ Object

Add a resource namespace

Parameters:

  • name (String)

    name of the module

  • uri (String)

    URI of the resource



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xml_schema/ns.rb', line 8

def self.add(name, uri)
  ns_module = self.const_set(name, Module.new)
  ns_module.module_eval "    def self.uri\n      URI(\\\"\#{uri.sub(/\\/?$/, '/')}\\\")\n    end\n\n    def self.to_s\n      \\\"\#{uri}\\\"\n    end\n\n    def self.[](value)\n      URI(\\\"\\\#{self}#\\\#{value}\\\")\n    end\n"
end