Sha256: a5441b2433cfefae3824c418c7d3c847154ec991ec295b00f680094f36069db5

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

module CIM

  class QualifierFlavorError < ArgumentError
    def initialize flavor
      @flavor = flavor
    end
    def to_s
      "#{@flavor} is not a valid qualifier flavor"
    end
  end

  class QualifierFlavors
    FLAVORS = [:amended, :enableoverride, :disableoverride, :restricted, :toinstance, :tosubclass, :translatable]
    attr_reader :flavors
    def initialize flavor
      @flavors = []
      self << flavor
    end
    def << flavor
      flavor.downcase! if flavor.kind_of? String
      f = flavor.to_sym
      raise QualifierFlavorError.new("#{flavor}") unless FLAVORS.include? f
      @flavors << f
      self
    end
    def to_sym
      @flavors.first
    end
    def to_s
      "Flavor(#{@flavors.join(', ')})"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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