Sha256: 4f0a2ff9cf0c1d64e90e1512ad930a422f362c7b8d5cbbf391332e0a081dfda0

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

#
# cim/named_element.rb - class CIM::NamedElement
#
# A pure-Ruby implementation of the CIM meta model.
#
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
#
# Licensed under the Ruby license
#

module CIM
  #
  # 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)
  #
  class NamedElement
    attr_reader :name, :qualifiers
    #
    # Create a NamedElement with a name and qualifiers
    #
    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
    #
    # Add a Qualifier to the NamedElements qualifiers
    #
    def << qualifier
      @qualifiers << CIM::Qualifier.normalize(qualifier)
    end
    #
    # Check if a Qualifier is included 
    #
    def include? qualifier
      @qualifiers.include? qualifier
    end
    alias includes? include?
    #
    # Returns a string representation of the NamedElement
    #
    def to_s
      s = ""
      s << "[#{@qualifiers.join(', ')}]\n " if @qualifiers
      s << "#{@name}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cim-1.4.2 lib/cim/named_element.rb
cim-1.4.1 lib/cim/named_element.rb
cim-1.4 lib/cim/named_element.rb
cim-1.3 lib/cim/named_element.rb