Class: Metanorma::Utils::Namespace
- Inherits:
-
Object
- Object
- Metanorma::Utils::Namespace
- Defined in:
- lib/utils/namespace.rb
Overview
NOTE: It was used in methods of an eigenclass of Metanorma::Utils.
Not sure if it's still used somewhere but could be.
Instance Method Summary collapse
-
#initialize(xmldoc) ⇒ Namespace
constructor
A new instance of Namespace.
- #ns(path) ⇒ Object
Constructor Details
#initialize(xmldoc) ⇒ Namespace
Returns a new instance of Namespace.
7 8 9 |
# File 'lib/utils/namespace.rb', line 7 def initialize(xmldoc) @namespace = xmldoc.root.namespace end |
Instance Method Details
#ns(path) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/utils/namespace.rb', line 11 def ns(path) return path if @namespace.nil? path.gsub(%r{/([a-zA-Z])}, "/xmlns:\\1") .gsub(%r{::([a-zA-Z])}, "::xmlns:\\1") .gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1") .gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1") end |