Class: RXaal::NSContainer
- Includes:
- Enumerable
- Defined in:
- lib/ns_container.rb
Instance Attribute Summary collapse
-
#name_to_ns ⇒ Object
readonly
Returns the value of attribute name_to_ns.
-
#namespaces ⇒ Object
readonly
Returns the value of attribute namespaces.
-
#uri_to_ns ⇒ Object
readonly
Returns the value of attribute uri_to_ns.
Instance Method Summary collapse
- #add_ns(uri, prefix = "") ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ NSContainer
constructor
A new instance of NSContainer.
Constructor Details
#initialize ⇒ NSContainer
Returns a new instance of NSContainer.
8 9 10 11 12 |
# File 'lib/ns_container.rb', line 8 def initialize @namespaces = Array.new @name_to_ns = Hash.new @uri_to_ns = Hash.new end |
Instance Attribute Details
#name_to_ns ⇒ Object (readonly)
Returns the value of attribute name_to_ns.
6 7 8 |
# File 'lib/ns_container.rb', line 6 def name_to_ns @name_to_ns end |
#namespaces ⇒ Object (readonly)
Returns the value of attribute namespaces.
6 7 8 |
# File 'lib/ns_container.rb', line 6 def namespaces @namespaces end |
#uri_to_ns ⇒ Object (readonly)
Returns the value of attribute uri_to_ns.
6 7 8 |
# File 'lib/ns_container.rb', line 6 def uri_to_ns @uri_to_ns end |
Instance Method Details
#add_ns(uri, prefix = "") ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ns_container.rb', line 14 def add_ns (uri, prefix="") ns = XaalNS.new(uri, prefix) if @uri_to_ns[uri] != nil namespaces = @namespaces.collect { |i| i != @uri_to_ns[uri]} @namespaces = namespaces end @namespaces.push(ns) @uri_to_ns[uri] = ns @name_to_ns[prefix] = ns return ns end |
#each ⇒ Object
26 27 28 |
# File 'lib/ns_container.rb', line 26 def each self.namespaces.each {|n| yield n} end |