Class: WBEM::CIMInstance
Instance Attribute Summary collapse
-
#classname ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“.
-
#path ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“.
-
#properties ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“.
-
#qualifiers ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“.
Instance Method Summary
collapse
Methods inherited from XMLObject
#cmpname, #eql?, #hash, #nilcmp, #toxml
Constructor Details
#initialize(classname, properties = {}, qualifiers = {}, path = nil) ⇒ CIMInstance
Returns a new instance of CIMInstance.
664
665
666
667
668
669
670
671
672
673
674
675
|
# File 'lib/wbem/cim_obj.rb', line 664
def initialize(classname, properties = {}, qualifiers = {},
path = nil)
@classname = classname
@qualifiers = NocaseHash.new(qualifiers)
@path = path
@properties = NocaseHash.new
properties.each do |k, v|
self[k]=v
end
end
|
Instance Attribute Details
#classname ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“
662
663
664
|
# File 'lib/wbem/cim_obj.rb', line 662
def classname
@classname
end
|
#path ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“
662
663
664
|
# File 'lib/wbem/cim_obj.rb', line 662
def path
@path
end
|
#properties ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“
662
663
664
|
# File 'lib/wbem/cim_obj.rb', line 662
def properties
@properties
end
|
#qualifiers ⇒ Object
The properties is indexed by name and points to CIMProperty instances.“”“
662
663
664
|
# File 'lib/wbem/cim_obj.rb', line 662
def qualifiers
@qualifiers
end
|
Instance Method Details
#<=>(other) ⇒ Object
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
# File 'lib/wbem/cim_obj.rb', line 692
def <=>(other)
if equal?(other)
return 0
elsif (!other.kind_of?(CIMInstance))
return 1
end
ret_val = cmpname(self.classname, other.classname)
ret_val = nilcmp(self.path, other.path) 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
end
|
#[](key) ⇒ Object
719
720
721
722
|
# File 'lib/wbem/cim_obj.rb', line 719
def [](key)
ret = self.properties[key]
ret = ret.value unless ret.nil?
end
|
#[]=(key, value) ⇒ Object
def iterkeys(self): return self.properties.iterkeys() def itervalues(self): return self.properties.itervalues() def iteritems(self): return self.properties.iteritems()
745
746
747
748
749
750
751
752
753
754
755
756
757
|
# File 'lib/wbem/cim_obj.rb', line 745
def []=(key, value)
unless (value.is_a?(CIMProperty))
unless WBEM.valid_cimtype?(value)
raise TypeError, "Must use a CIM type assigning numeric values."
end
value = CIMProperty.new(key, value)
end
self.properties[key] = value
end
|
#clone ⇒ Object
677
678
679
|
# File 'lib/wbem/cim_obj.rb', line 677
def clone
CIMInstance.new(@classname, @properties, @qualifiers, @path)
end
|
#delete(key) ⇒ Object
723
724
725
|
# File 'lib/wbem/cim_obj.rb', line 723
def delete(key)
self.properties.delete(key)
end
|
#fetch(key) ⇒ Object
A whole bunch of dictionary methods that map to the equivalent operation on self.properties.
716
717
718
|
# File 'lib/wbem/cim_obj.rb', line 716
def fetch(key)
return self.properties.fetch(key)
end
|
#has_key?(key) ⇒ Boolean
729
730
731
|
# File 'lib/wbem/cim_obj.rb', line 729
def has_key?(key)
self.properties.has_key?(key)
end
|
#keys ⇒ Object
732
733
734
|
# File 'lib/wbem/cim_obj.rb', line 732
def keys
self.properties.keys()
end
|
#length ⇒ Object
726
727
728
|
# File 'lib/wbem/cim_obj.rb', line 726
def length
self.properties.length
end
|
#to_a ⇒ Object
738
739
740
|
# File 'lib/wbem/cim_obj.rb', line 738
def to_a
self.properties.to_a.collect { |k, v| [k, v.value] }
end
|
#to_s ⇒ Object
707
708
709
710
711
|
# File 'lib/wbem/cim_obj.rb', line 707
def to_s
"#{self.class}(classname=#{self.classname} ...)"
end
|
#tocimxml ⇒ Object
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
# File 'lib/wbem/cim_obj.rb', line 759
def tocimxml
props = []
self.properties.each do |key, prop|
if (prop.is_a?(CIMProperty))
props << prop
else
props << CIMProperty.new(key, prop)
end
end
instance_xml = INSTANCE.new(self.classname,
props.collect { |p| p.tocimxml},
self.qualifiers.values.collect { |q| q.tocimxml})
if self.path.nil?
return instance_xml
end
return VALUE_NAMEDINSTANCE.new(self.path.tocimxml,
instance_xml)
end
|
#values ⇒ Object
735
736
737
|
# File 'lib/wbem/cim_obj.rb', line 735
def values
self.properties.values.collect { |v| v.value }
end
|