Class: WBEM::CIMClass

Inherits:
XMLObject show all
Includes:
Comparable
Defined in:
lib/wbem/cim_obj.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from XMLObject

#cmpname, #eql?, #hash, #nilcmp, #toxml

Constructor Details

#initialize(classname, properties = {}, qualifiers = {}, methods = {}, superclass = nil) ⇒ CIMClass

Returns a new instance of CIMClass.



785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
# File 'lib/wbem/cim_obj.rb', line 785

def initialize(classname, properties = {}, qualifiers = {},
               methods = {}, superclass = nil)
    unless (classname.kind_of?(String))
        raise TypeError, "classname must be a String"
    end
    @classname = classname
    @properties = NocaseHash.new
    unless properties.nil?
        properties.each do |k, v|
            @properties[k]=v
        end
    end
    @qualifiers = NocaseHash.new(qualifiers)
    @cim_methods = NocaseHash.new(methods)
    @superclass = superclass
end

Instance Attribute Details

#cim_methodsObject

Returns the value of attribute cim_methods.



783
784
785
# File 'lib/wbem/cim_obj.rb', line 783

def cim_methods
  @cim_methods
end

#classnameObject

Returns the value of attribute classname.



783
784
785
# File 'lib/wbem/cim_obj.rb', line 783

def classname
  @classname
end

#propertiesObject

Returns the value of attribute properties.



783
784
785
# File 'lib/wbem/cim_obj.rb', line 783

def properties
  @properties
end

#qualifiersObject

Returns the value of attribute qualifiers.



783
784
785
# File 'lib/wbem/cim_obj.rb', line 783

def qualifiers
  @qualifiers
end

#superclassObject

Returns the value of attribute superclass.



783
784
785
# File 'lib/wbem/cim_obj.rb', line 783

def superclass
  @superclass
end

Instance Method Details

#<=>(other) ⇒ Object



828
829
830
831
832
833
834
835
836
837
838
839
840
# File 'lib/wbem/cim_obj.rb', line 828

def <=>(other)
    if equal?(other)
        return 0
    elsif (!other.kind_of?(CIMClass))
        return 1
    end
    ret_val = cmpname(self.classname, other.classname)
    ret_val = cmpname(self.superclass, other.superclass) if (ret_val == 0)
    ret_val = nilcmp(self.properties, other.properties) if (ret_val == 0)
    ret_val = nilcmp(self.qualifiers, other.qualifiers) if (ret_val == 0)
    ret_val = nilcmp(self.cim_methods, other.cim_methods) if (ret_val == 0)
    ret_val
end

#cloneObject



802
803
804
805
# File 'lib/wbem/cim_obj.rb', line 802

def clone
    return CIMClass.new(@classname, @properties, @qualifiers,
                        @cim_methods, @superclass)
end

#to_sObject



824
825
826
# File 'lib/wbem/cim_obj.rb', line 824

def to_s
    "#{self.class}(#{self.classname}, ...)"
end

#tocimxmlObject



842
843
844
845
846
847
848
# File 'lib/wbem/cim_obj.rb', line 842

def tocimxml
    return CLASS.new(self.classname,
                     self.properties.values.collect {|p| p.tocimxml()},
                     self.cim_methods.values.collect {|m| m.tocimxml()},
                     self.qualifiers.values.collect {|q| q.tocimxml()},
                     self.superclass)
end