class WsdlMapper::Dom::Name

Represents a fully qualified name of an XML element, that means, it contains both the namespace, and the local name

Attributes

name[R]

@!attribute [r] name

@return [String] Local name of this fully qualified name.
ns[R]

@!attribute [r] name

@return [String] Local name of this fully qualified name.

Public Class Methods

get(ns, name) click to toggle source

Gets the {Name} object for the given namespace and local name from the name cache to minimize the number of strings + objects used. @param [String] ns Namespace URI @param [String] name Local name @return [Name]

# File lib/wsdl_mapper/dom/name.rb, line 57
def self.get(ns, name)
  @cache ||= Hash.new do |h, k|
    h[k] = Hash.new do |h2, k2|
      h2[k2] = new k, k2
    end
  end

  name = name.to_s unless name.is_a?(String)
  @cache[ns][name]
end
new(ns, name) click to toggle source

Initialize a new fully qualified name. @param [String] ns @param [String] name

# File lib/wsdl_mapper/dom/name.rb, line 17
def initialize(ns, name)
  @ns, @name = ns, name
  @hash = [ns, name].hash
end

Public Instance Methods

==(other) click to toggle source

@see {#eql?}

# File lib/wsdl_mapper/dom/name.rb, line 30
def ==(other)
  eql? other
end
eql?(other) click to toggle source

Check if this fully qualified name is equal to `other`. @param [Name] other Other name to compare to. @return [true, false] true if `self` and `other` are equal both in namespace and in local name.

# File lib/wsdl_mapper/dom/name.rb, line 25
def eql?(other)
  self.class == other.class && name == other.name && ns == other.ns
end
hash() click to toggle source
# File lib/wsdl_mapper/dom/name.rb, line 34
def hash
  @hash
end
to_a() click to toggle source

Returns the namespace and local name as elements of a tuple / 2-element array: `[“namespace-uri”, “local-name”]` @return [Array<String>] An array containing namespace & local name.

# File lib/wsdl_mapper/dom/name.rb, line 48
def to_a
  [ns, name]
end
to_s() click to toggle source

Returns the fully qualified name as string representation in the format `“{namespace-uri}/local-name”` @return [String] String representation of this FQN

# File lib/wsdl_mapper/dom/name.rb, line 41
def to_s
  "{#{ns}}#{name}"
end