Class: CIM::QualifierDeclaration
- Inherits:
-
NamedElement
- Object
- NamedElement
- CIM::QualifierDeclaration
- Defined in:
- lib/cim/qualifier_declaration.rb
Overview
A Qualifier is a modifier containing information to describe a Class, an Instance, a Property, a Method or a parameter.
A qualifier needs to be declared before it can be used.
Typical qualifiers are e.g.
- Description
-
(string type) to add a textual information about an element of the CIM model.
- Counter,Gauge
-
to explain how a numeric value is to be interpreted
- Deprecated
-
to denote end-of-life for model elements
- Min, Max
-
(MinLen, MaxLen, MinValue, MaxValue) limits
A QualifierDeclaration declares a qualifier by
- name
-
(String)
- type
-
(Type) (defaults to boolean)
- default value
-
(Variant) (defaults to false)
- scopes
-
(QualifierScopes) (where the qualifier can be used)
- flavor
-
(QualifierFlavors) (how the qualifier is applied)
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#flavors ⇒ Object
readonly
Returns the value of attribute flavors.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from NamedElement
Instance Method Summary collapse
-
#==(q) ⇒ Object
Test for equality by comparing name and type.
-
#initialize(name, type = :boolean, default = false, scopes = nil, flavors = nil) ⇒ QualifierDeclaration
constructor
Create a new QualifierDeclaration.
-
#to_s ⇒ Object
returns a String representation in MOF syntax format.
-
#to_sym ⇒ Object
return a Symbol representation of the qualifier name.
Methods inherited from NamedElement
Constructor Details
#initialize(name, type = :boolean, default = false, scopes = nil, flavors = nil) ⇒ QualifierDeclaration
Create a new QualifierDeclaration
37 38 39 40 41 42 43 |
# File 'lib/cim/qualifier_declaration.rb', line 37 def initialize name, type = :boolean, default = false, scopes = nil, flavors = nil @type = (type.kind_of? Type) ? type : Type.new(type) @default = (default.nil? || default.is_a?(CIM::Variant)) ? default : CIM::Variant.new(@type, default) @scopes = scopes @flavors = flavors super name end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
33 34 35 |
# File 'lib/cim/qualifier_declaration.rb', line 33 def default @default end |
#flavors ⇒ Object (readonly)
Returns the value of attribute flavors.
33 34 35 |
# File 'lib/cim/qualifier_declaration.rb', line 33 def flavors @flavors end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
33 34 35 |
# File 'lib/cim/qualifier_declaration.rb', line 33 def scopes @scopes end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
33 34 35 |
# File 'lib/cim/qualifier_declaration.rb', line 33 def type @type end |
Instance Method Details
#==(q) ⇒ Object
Test for equality by comparing name and type
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cim/qualifier_declaration.rb', line 47 def == q # puts "QualifierDeclaration(#{@name}:#{@type}) == #{q.class}(#{q})" case q when QualifierDeclaration (@name.downcase == q.name.downcase) && (@type.nil? || q.type.nil? || (@type == q.type)) when String @name.downcase == q.downcase when Symbol @name.downcase == q.to_s.downcase else false end end |
#to_s ⇒ Object
returns a String representation in MOF syntax format
70 71 72 73 74 75 76 |
# File 'lib/cim/qualifier_declaration.rb', line 70 def to_s s = "Qualifier #{@name} : #{@type}" s << " = #{@default}" if @default s << ",\n\t#{@scopes}" if @scopes s << ",\n\t#{@flavors}" if @flavors s end |
#to_sym ⇒ Object
return a Symbol representation of the qualifier name
64 65 66 |
# File 'lib/cim/qualifier_declaration.rb', line 64 def to_sym @name.downcase.to_sym end |