Class: WsdlMapper::Dom::Name
- Inherits:
-
Object
- Object
- WsdlMapper::Dom::Name
- Defined in:
- lib/wsdl_mapper/dom/name.rb
Overview
Represents a fully qualified name of an XML element, that means, it contains both the namespace, and the local name
Instance Attribute Summary (collapse)
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) ns
readonly
Returns the value of attribute ns.
Class Method Summary (collapse)
-
+ (Name) get(ns, name)
Gets the Name object for the given namespace and local name from the name cache to minimize the number of strings + objects used.
Instance Method Summary (collapse)
- - (Object) ==(other)
-
- (true, false) eql?(other)
Check if this fully qualified name is equal to
other
. - - (Object) hash
-
- (Name) initialize(ns, name)
constructor
Initialize a new fully qualified name.
-
- (Array<String>) to_a
Returns the namespace and local name as elements of a tuple / 2-element array:
["namespace-uri", "local-name"]
. -
- (String) to_s
Returns the fully qualified name as string representation in the format
"{namespace-uri}/local-name"
.
Constructor Details
- (Name) initialize(ns, name)
Initialize a new fully qualified name.
17 18 19 20 |
# File 'lib/wsdl_mapper/dom/name.rb', line 17 def initialize(ns, name) @ns, @name = ns, name @hash = [ns, name].hash end |
Instance Attribute Details
- (Object) name (readonly)
Returns the value of attribute name
12 |
# File 'lib/wsdl_mapper/dom/name.rb', line 12 attr_reader :ns, :name |
- (Object) ns (readonly)
Returns the value of attribute ns
|
# File 'lib/wsdl_mapper/dom/name.rb', line 6
|
Class Method Details
+ (Name) get(ns, name)
Gets the WsdlMapper::Dom::Name object for the given namespace and local name from the name cache to minimize the number of strings + objects used.
57 58 59 60 61 62 63 64 65 66 |
# 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 |
Instance Method Details
- (Object) ==(other)
30 31 32 |
# File 'lib/wsdl_mapper/dom/name.rb', line 30 def ==(other) eql? other end |
- (true, false) eql?(other)
Check if this fully qualified name is equal to other
.
25 26 27 |
# File 'lib/wsdl_mapper/dom/name.rb', line 25 def eql?(other) self.class == other.class && name == other.name && ns == other.ns end |
- (Object) hash
34 35 36 |
# File 'lib/wsdl_mapper/dom/name.rb', line 34 def hash @hash end |
- (Array<String>) to_a
Returns the namespace and local name as elements of a tuple / 2-element array:
["namespace-uri", "local-name"]
48 49 50 |
# File 'lib/wsdl_mapper/dom/name.rb', line 48 def to_a [ns, name] end |
- (String) to_s
Returns the fully qualified name as string representation in the format
"{namespace-uri}/local-name"
41 42 43 |
# File 'lib/wsdl_mapper/dom/name.rb', line 41 def to_s "{#{ns}}#{name}" end |