Sha256: 98e9dabff123798d8a46b96c827785991173a65463f7884acc7ab11fc31f31cb

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

module CIM
    
  class QualifierScopeError < ArgumentError
    def initialize element, msg = nil
      @element = element
      super msg
    end
    def to_s
      "#{@element} is not a valid meta element for scopes"
    end
  end

  class QualifierScope
    META_ELEMENTS = [ :schema, :class, :association, :indication, :qualifier, :property, :reference, :method, :parameter, :any ]
    attr_reader :elements
    def initialize element = :any
      @elements = []
      self << element
    end
    def << element
      element.downcase! if element.is_a?(String)
      e = element.to_sym
      raise QualifierScopeError.new(element) unless META_ELEMENTS.include?(e)
      @elements << e
      self
    end
    def has? qualifier
      @elements.include? qualifier
    end
    def to_s
      "Scope(#{@elements.join(', ')})"
    end
    def to_sym
      @elements.first
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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