Class: XSD::QName
- Inherits:
-
Object
- Object
- XSD::QName
- Defined in:
- lib/xsd/qname.rb
Constant Summary collapse
- NormalizedNameRegexp =
/^\{([^}]*)\}(.*)$/
- EMPTY =
QName.new.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #==(rhs) ⇒ Object
- #===(rhs) ⇒ Object
- #dump ⇒ Object
- #dup_name(name) ⇒ Object
- #eql?(rhs) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(namespace = nil, name = nil) ⇒ QName
constructor
A new instance of QName.
- #inspect ⇒ Object
- #match(rhs) ⇒ Object
- #parse(str) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(namespace = nil, name = nil) ⇒ QName
Returns a new instance of QName.
17 18 19 20 21 |
# File 'lib/xsd/qname.rb', line 17 def initialize(namespace = nil, name = nil) @namespace = namespace @name = name @source = nil end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
14 15 16 |
# File 'lib/xsd/qname.rb', line 14 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace
13 14 15 |
# File 'lib/xsd/qname.rb', line 13 def namespace @namespace end |
#source ⇒ Object
Returns the value of attribute source
15 16 17 |
# File 'lib/xsd/qname.rb', line 15 def source @source end |
Instance Method Details
#==(rhs) ⇒ Object
43 44 45 |
# File 'lib/xsd/qname.rb', line 43 def ==(rhs) !rhs.nil? and @namespace == rhs.namespace and @name == rhs.name end |
#===(rhs) ⇒ Object
47 48 49 |
# File 'lib/xsd/qname.rb', line 47 def ===(rhs) (self == rhs) end |
#dump ⇒ Object
27 28 29 30 31 |
# File 'lib/xsd/qname.rb', line 27 def dump ns = @namespace.nil? ? 'nil' : @namespace.dump name = @name.nil? ? 'nil' : @name.dump "XSD::QName.new(#{ns}, #{name})" end |
#dup_name(name) ⇒ Object
23 24 25 |
# File 'lib/xsd/qname.rb', line 23 def dup_name(name) XSD::QName.new(@namespace, name) end |
#eql?(rhs) ⇒ Boolean
51 52 53 |
# File 'lib/xsd/qname.rb', line 51 def eql?(rhs) (self == rhs) end |
#hash ⇒ Object
55 56 57 |
# File 'lib/xsd/qname.rb', line 55 def hash @namespace.hash ^ @name.hash end |
#inspect ⇒ Object
63 64 65 66 |
# File 'lib/xsd/qname.rb', line 63 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, "{#{ namespace }}#{ name }") end |
#match(rhs) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/xsd/qname.rb', line 33 def match(rhs) if rhs.namespace and (rhs.namespace != @namespace) return false end if rhs.name and (rhs.name != @name) return false end true end |
#parse(str) ⇒ Object
69 70 71 72 |
# File 'lib/xsd/qname.rb', line 69 def parse(str) NormalizedNameRegexp =~ str self.new($1, $2) end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/xsd/qname.rb', line 59 def to_s "{#{ namespace }}#{ name }" end |