Class: CIM::Class
- Inherits:
-
NamedElement
- Object
- NamedElement
- CIM::Class
- Defined in:
- lib/cim/class.rb
Overview
A Class is a central element in the object-oriented CIM schema
Classes can be derived from other classes, creating a hierachical model.
Classes have qualifiers to describe the class characteristics and contain features (properties or methods).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#superclass ⇒ Object
readonly
Returns the value of attribute superclass.
Attributes inherited from NamedElement
Instance Method Summary collapse
-
#association? ⇒ Boolean
true if class has associations (association provider).
-
#each_key ⇒ Object
Iterate over features flagged as keys.
-
#features ⇒ Object
Ensure features can be enumerated.
-
#indication? ⇒ Boolean
true if class has indications (indication provider).
-
#initialize(name, qualifiers = nil, alias_name = nil, superclass = nil, features = nil) ⇒ Class
constructor
A new instance of Class.
-
#instance? ⇒ Boolean
true if class has instances (instance provider).
-
#method? ⇒ Boolean
true if class has methods (method provider).
- #method_missing(name, *args) ⇒ Object
-
#to_s ⇒ Object
returns a string representation in MOF syntax format.
Methods inherited from NamedElement
Constructor Details
#initialize(name, qualifiers = nil, alias_name = nil, superclass = nil, features = nil) ⇒ Class
Returns a new instance of Class.
51 52 53 54 55 56 57 58 |
# File 'lib/cim/class.rb', line 51 def initialize name, qualifiers = nil, alias_name = nil, superclass = nil, features = nil @alias_name = alias_name @superclass = superclass features = nil if features.kind_of?(::Enumerable) && features.empty? @features = features # puts "CIM::Class.new(#{@features})" super name, qualifiers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
60 61 62 |
# File 'lib/cim/class.rb', line 60 def method_missing name, *args @qualifiers[name] end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
21 22 23 |
# File 'lib/cim/class.rb', line 21 def alias_name @alias_name end |
#superclass ⇒ Object (readonly)
Returns the value of attribute superclass.
21 22 23 |
# File 'lib/cim/class.rb', line 21 def superclass @superclass end |
Instance Method Details
#association? ⇒ Boolean
true if class has associations (association provider)
101 102 103 |
# File 'lib/cim/class.rb', line 101 def association? include? :association end |
#each_key ⇒ Object
Iterate over features flagged as keys
73 74 75 76 77 |
# File 'lib/cim/class.rb', line 73 def each_key features.each do |f| yield f if f.key? end end |
#features ⇒ Object
Ensure features can be enumerated
67 68 69 |
# File 'lib/cim/class.rb', line 67 def features @features || [] end |
#indication? ⇒ Boolean
true if class has indications (indication provider)
107 108 109 |
# File 'lib/cim/class.rb', line 107 def indication? include? :indication end |
#instance? ⇒ Boolean
true if class has instances (instance provider)
81 82 83 84 85 86 87 88 |
# File 'lib/cim/class.rb', line 81 def instance? features.each do |f| next if f.reference? next if f.method? return true if f.property? end false end |
#method? ⇒ Boolean
true if class has methods (method provider)
92 93 94 95 96 97 |
# File 'lib/cim/class.rb', line 92 def method? features.each do |f| return true if f.method? end false end |
#to_s ⇒ Object
returns a string representation in MOF syntax format
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/cim/class.rb', line 113 def to_s s = "" s << "[#{@qualifiers.join(', ')}]\n" if @qualifiers s << "class #{@name}" s << " AS #{@alias_name}" if @alias_name s << " : #{@superclass}" if @superclass s << " {" if @features f = @features.join(";\n ") s << "\n #{f};\n" end s << "}" end |