Class: XSD::QName
Constant Summary collapse
- NormalizedNameRegexp =
/^\{([^}]*)\}(.*)$/
- EMPTY =
QName.new.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #==(rhs) ⇒ Object
- #===(rhs) ⇒ Object
- #dump(predefined_ns = nil) ⇒ 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.
18 19 20 21 22 |
# File 'lib/xsd/qname.rb', line 18 def initialize(namespace = nil, name = nil) @namespace = namespace ? namespace.to_s : nil @name = name ? name.to_s : nil @source = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/xsd/qname.rb', line 15 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
14 15 16 |
# File 'lib/xsd/qname.rb', line 14 def namespace @namespace end |
#source ⇒ Object
Returns the value of attribute source.
16 17 18 |
# File 'lib/xsd/qname.rb', line 16 def source @source end |
Instance Method Details
#==(rhs) ⇒ Object
45 46 47 |
# File 'lib/xsd/qname.rb', line 45 def ==(rhs) !rhs.nil? and @namespace == rhs.namespace and @name == rhs.name end |
#===(rhs) ⇒ Object
49 50 51 |
# File 'lib/xsd/qname.rb', line 49 def ===(rhs) (self == rhs) end |
#dump(predefined_ns = nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/xsd/qname.rb', line 28 def dump(predefined_ns = nil) ns = predefined_ns ns ||= @namespace.nil? ? 'nil' : @namespace.dump name = @name.nil? ? 'nil' : @name.dump "XSD::QName.new(#{ns}, #{name})" end |
#dup_name(name) ⇒ Object
24 25 26 |
# File 'lib/xsd/qname.rb', line 24 def dup_name(name) XSD::QName.new(@namespace, name) end |
#eql?(rhs) ⇒ Boolean
53 54 55 |
# File 'lib/xsd/qname.rb', line 53 def eql?(rhs) (self == rhs) end |
#hash ⇒ Object
57 58 59 |
# File 'lib/xsd/qname.rb', line 57 def hash @namespace.hash ^ @name.hash end |
#inspect ⇒ Object
65 66 67 68 |
# File 'lib/xsd/qname.rb', line 65 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, "{#{ namespace }}#{ name }") end |
#match(rhs) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/xsd/qname.rb', line 35 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
71 72 73 74 |
# File 'lib/xsd/qname.rb', line 71 def parse(str) NormalizedNameRegexp =~ str self.new($1, $2) end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/xsd/qname.rb', line 61 def to_s "{#{ namespace }}#{ name }" end |