Class: RXaal::NSContainer

Inherits:
Object show all
Includes:
Enumerable
Defined in:
lib/ns_container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNSContainer

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_nsObject (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

#namespacesObject (readonly)

Returns the value of attribute namespaces.



6
7
8
# File 'lib/ns_container.rb', line 6

def namespaces
  @namespaces
end

#uri_to_nsObject (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

#eachObject



26
27
28
# File 'lib/ns_container.rb', line 26

def each
  self.namespaces.each {|n| yield n}
end