Class: Vectory::SvgMapping::Namespace
- Inherits:
-
Object
- Object
- Vectory::SvgMapping::Namespace
- Defined in:
- lib/vectory/svg_mapping.rb
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.
6 7 8 |
# File 'lib/vectory/svg_mapping.rb', line 6 def initialize(xmldoc) @namespace = xmldoc.root.namespace end |
Instance Method Details
#ns(path) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/vectory/svg_mapping.rb', line 10 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 |