Class: WBEM::CIMParameter

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(name, type, reference_class = nil, is_array = nil, array_size = nil, qualifiers = {}) ⇒ CIMParameter

Returns a new instance of CIMParameter.



914
915
916
917
918
919
920
921
922
# File 'lib/wbem/cim_obj.rb', line 914

def initialize(name, type, reference_class=nil, is_array = nil,
               array_size = nil, qualifiers = {})
    @name = name
    @param_type = type
    @reference_class = reference_class
    @is_array = is_array
    @array_size = array_size
    @qualifiers = NocaseHash.new(qualifiers)
end

Instance Attribute Details

#array_sizeObject

Returns the value of attribute array_size.



912
913
914
# File 'lib/wbem/cim_obj.rb', line 912

def array_size
  @array_size
end

#is_arrayObject

Returns the value of attribute is_array.



912
913
914
# File 'lib/wbem/cim_obj.rb', line 912

def is_array
  @is_array
end

#nameObject

Returns the value of attribute name.



912
913
914
# File 'lib/wbem/cim_obj.rb', line 912

def name
  @name
end

#param_typeObject

Returns the value of attribute param_type.



912
913
914
# File 'lib/wbem/cim_obj.rb', line 912

def param_type
  @param_type
end

#qualifiersObject

Returns the value of attribute qualifiers.



912
913
914
# File 'lib/wbem/cim_obj.rb', line 912

def qualifiers
  @qualifiers
end

#reference_classObject

Returns the value of attribute reference_class.



912
913
914
# File 'lib/wbem/cim_obj.rb', line 912

def reference_class
  @reference_class
end

Instance Method Details

#<=>(other) ⇒ Object



937
938
939
940
941
942
943
944
945
946
947
948
949
950
# File 'lib/wbem/cim_obj.rb', line 937

def <=>(other)
    if equal?(other)
        return 0
    elsif (!other.kind_of?(CIMParameter ))
        return 1
    end
    ret_val = cmpname(self.name, other.name)
    ret_val = nilcmp(self.param_type, other.param_type) if (ret_val == 0)
    ret_val = cmpname(self.reference_class, other.reference_class) if (ret_val == 0)
    ret_val = nilcmp(self.is_array, other.is_array) if (ret_val == 0)
    ret_val = nilcmp(self.array_size, other.array_size) if (ret_val == 0)
    ret_val = nilcmp(self.qualifiers, other.qualifiers) if (ret_val == 0)
    ret_val
end

#cloneObject



924
925
926
927
# File 'lib/wbem/cim_obj.rb', line 924

def clone
    return CIMParameter.new(@name, @param_type, @reference_class, 
                            @is_array, @array_size, @qualifiers)
end

#to_sObject



933
934
935
# File 'lib/wbem/cim_obj.rb', line 933

def to_s
    "#{self.class}(name=#{self.name}, type=#{self.param_type}, is_array=#{self.is_array})"
end

#tocimxmlObject



952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
# File 'lib/wbem/cim_obj.rb', line 952

def tocimxml
    if self.param_type == 'reference'
        if self.is_array
            return PARAMETER_REFARRAY.new(self.name,
                                          self.reference_class,
                                          array_size.nil? ? nil : self.array_size.to_s,
                                          self.qualifiers.values.collect {|q| q.tocimxml()})
        else
            return PARAMETER_REFERENCE.new(self.name,
                                           self.reference_class,
                                           self.qualifiers.values.collect {|q| q.tocimxml()})
        end
    elsif self.is_array
        return PARAMETER_ARRAY.new(self.name,
                                   self.param_type,
                                   array_size.nil? ? nil : self.array_size.to_s,
                                   self.qualifiers.values.collect { |q| q.tocimxml})
    else
        return PARAMETER.new(self.name,
                             self.param_type,
                             self.qualifiers.values.collect { |q| q.tocimxml})
    end
end