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 <<-HERE
    def self.uri
      URI(\"#{uri.sub(/\/?$/, '/')}\")
    end

    def self.to_s
      \"#{uri}\"
    end

    def self.[](value)
      URI(\"\#{self}#\#{value}\")
    end
HERE
end