Class: CIM::NamedElement
- Inherits:
-
Object
- Object
- CIM::NamedElement
- Defined in:
- lib/cim/named_element.rb
Overview
The NamedElement is a basic building block for the CIM schema, acting as a base class for Class and Property
A NamedElement has a name (String) and qualifiers (Qualifiers)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#qualifiers ⇒ Object
readonly
Returns the value of attribute qualifiers.
Instance Method Summary collapse
-
#<<(qualifier) ⇒ Object
Add a Qualifier to the NamedElements qualifiers.
-
#include?(qualifier) ⇒ Boolean
(also: #includes?)
Check if a Qualifier is included.
-
#initialize(name, qualifiers = nil) ⇒ NamedElement
constructor
Create a NamedElement with a name and qualifiers.
-
#to_s ⇒ Object
Returns a string representation of the NamedElement.
Constructor Details
#initialize(name, qualifiers = nil) ⇒ NamedElement
Create a NamedElement with a name and qualifiers
23 24 25 26 27 |
# File 'lib/cim/named_element.rb', line 23 def initialize name, qualifiers = nil raise "NamedElement must have a name" unless name @name = name.to_s @qualifiers = (qualifiers) ? CIM::QualifierSet.normalize(qualifiers) : CIM::QualifierSet.new end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/cim/named_element.rb', line 19 def name @name end |
#qualifiers ⇒ Object (readonly)
Returns the value of attribute qualifiers.
19 20 21 |
# File 'lib/cim/named_element.rb', line 19 def qualifiers @qualifiers end |
Instance Method Details
#<<(qualifier) ⇒ Object
Add a Qualifier to the NamedElements qualifiers
31 32 33 |
# File 'lib/cim/named_element.rb', line 31 def << qualifier @qualifiers << CIM::Qualifier.normalize(qualifier) end |
#include?(qualifier) ⇒ Boolean Also known as: includes?
Check if a Qualifier is included
37 38 39 |
# File 'lib/cim/named_element.rb', line 37 def include? qualifier @qualifiers.include? qualifier end |
#to_s ⇒ Object
Returns a string representation of the NamedElement
44 45 46 47 48 |
# File 'lib/cim/named_element.rb', line 44 def to_s s = "" s << "[#{@qualifiers.join(', ')}]\n " if @qualifiers s << "#{@name}" end |