Class: WBEM::XMLObject
- Inherits:
-
Object
- Object
- WBEM::XMLObject
- Defined in:
- lib/wbem/cim_obj.rb
Direct Known Subclasses
CIMClass, CIMInstance, CIMInstanceName, CIMMethod, CIMObjectLocation, CIMParameter, CIMProperty, CIMQualifier
Instance Method Summary collapse
- #cmpname(name1, name2, downcase_strings = true) ⇒ Object
-
#eql?(other) ⇒ Boolean
probably not the best equality method, as trivial differences such as attribute order will affect the results, but better than the default eql? method defined in object – subclasses can define this in a better way.
- #hash ⇒ Object
- #nilcmp(obj1, obj2) ⇒ Object
-
#toxml ⇒ Object
“”“Base class for objects that produce cim_xml document fragments.”“”.
Instance Method Details
#cmpname(name1, name2, downcase_strings = true) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/wbem/cim_obj.rb', line 134 def cmpname(name1, name2, downcase_strings = true) #"""Compare to CIM names. The comparison is done #case-insensitvely, and one or both of the names may be None.""" if name1.nil? and name2.nil? return 0 end unless (name1 || name2) return 0 end if name1.nil? return -1 end if name2.nil? return 1 end if (downcase_strings) name1.downcase <=> name2.downcase elsif (name2.is_a?(Boolean)) (name2 <=> name1)*-1 elsif (!name1.methods.include?("<=>")) (name1 == name2) ? 0 : 1 elsif ((name1.nil? || name1 == false) && (name2.nil? || name2 == false)) return 0 else name1 <=> name2 end end |
#eql?(other) ⇒ Boolean
probably not the best equality method, as trivial differences such as attribute order will affect the results, but better than the default eql? method defined in object – subclasses can define this in a better way
126 127 128 |
# File 'lib/wbem/cim_obj.rb', line 126 def eql?(other) (self.toxml == other.toxml) end |
#hash ⇒ Object
119 120 121 |
# File 'lib/wbem/cim_obj.rb', line 119 def hash self.toxml().hash end |
#nilcmp(obj1, obj2) ⇒ Object
130 131 132 |
# File 'lib/wbem/cim_obj.rb', line 130 def nilcmp(obj1, obj2) cmpname(obj1, obj2, false) end |
#toxml ⇒ Object
“”“Base class for objects that produce cim_xml document fragments.”“”
113 114 115 116 117 118 |
# File 'lib/wbem/cim_obj.rb', line 113 def toxml #"""Return the XML string representation of ourselves.""" ret = "" self.tocimxml().write(ret) return ret end |