Sha256: 5cc4ec4519210973398165ad30b379874fa16d902473c92ef3e51855bc8f7120

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module CIM
  class Qualifier
    attr_reader :declaration, :value, :flavor
    def initialize declaration, value = nil, flavor = nil
      raise "Not a CIM::QualifierDeclaration: #{declaration.inspect}" unless declaration.is_a?(CIM::QualifierDeclaration)
      @declaration = declaration
      @value = value
      @flavor = flavor
    end
    def == q
      #	puts "CIM::Qualifier ->#{self} == #{q.inspect}"
      case q
      when CIM::Qualifier
	(@declaration == q.declaration) &&
	(@value == q.value) &&
	(@flavor == q.flavor)
      when CIM::QualifierDeclaration
	@declaration == q  
      when Symbol
	q.to_s.downcase == @declaration.name.downcase && @value.nil? && @flavor.nil?
      else
	false
      end
    end
    def to_sym
      @declaration.downcase.to_sym
    end
    def to_s
      s = "#{@declaration.name.capitalize}"
      case @value
      when nil:
      when Array:
	s << " {#{@value.join(', ')}}"
      else
	s << "(#{@value.inspect})"
      end
      s << " #{@flavor}" if @flavor
      s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cim-0.3.0 lib/cim/qualifier.rb