Sha256: fe022a27a5748e3bafc837969e00e2bd55aa4cad2ea669d3002a14c0cc09cd8c

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

#
# cim/class_feature.rb - class CIM::ClassFeature
#
# 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
  #
  # ClassFeature is the base class for Class Property and Method
  #
  # A ClassFeature has a type (Type), name (String), and optional Qualifiers
  #
  # Access to ClassFeature attributes is *protected*, use the derived
  # classes Property, Method and Reference
  #
  class ClassFeature < NamedElement
    attr_reader :type
    #
    # if has key qualifier
    #
    def key?
      @qualifiers && @qualifiers.include?(:key,:bool)
    end
    #
    # if static (class-level) feature
    #
    def static?
      false
    end
    #
    # if Property
    #
    def property?
      false
    end
    #
    # if Method
    #
    def method?
      false
    end
    #
    # if Reference
    #
    def reference?
      false
    end
    protected
    def initialize type, name, qualifiers = nil
    # :notnew:
      @type = (type.is_a? CIM::Type) ? type : CIM::Type.new(type)
      super name, qualifiers
    end
    #
    # returns a string representation in MOF syntax format
    #
    def to_s
      s = ""
      s << "#{@qualifiers}\n  " if @qualifiers
      case @type
      when CIM::Array
	s << "#{@type.type} #{@name}[]"
      else
	s << "#{@type} #{@name}"
      end
      s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cim-0.5.0 lib/cim/class_feature.rb