lib/cim/qualifier_scopes.rb in cim-0.5.0 vs lib/cim/qualifier_scopes.rb in cim-1.3

- old
+ new

@@ -7,11 +7,11 @@ # # Licensed under the Ruby license # module CIM - class QualifierScopesError < ArgumentError + class QualifierScopeError < ArgumentError # # Raised if wrong Scope passed # def initialize element, msg = nil @element = element @@ -20,24 +20,22 @@ def to_s "#{@element} is not a valid meta element for scopes" end end - class QualifierScopes + class QualifierScopes < ::Array META_ELEMENTS = [ :schema, :class, :association, :indication, :qualifier, :property, :reference, :method, :parameter, :any ] - attr_reader :elements # # call-seq: # QualifierScopes.new => qualifier_scopes # QualifierScopes.new(:association) => qualifier_scopes # QualifierScopes.new("association") => qualifier_scopes # QualifierScopes.new("Association") => qualifier_scopes # # raises QualifierScopesError # def initialize *elements - @elements = [] elements.flatten.each do |element| self << element end end # @@ -47,11 +45,11 @@ # qualifier_scopes << "Association" # # raises QualifierScopesError # def << element - @elements << (normalize element) + self.push(normalize element) self end # # call-seq: # qualifier_scopes.has? :association @@ -59,29 +57,24 @@ # qualifier_scopes.has? "Association" # # raises QualifierScopesError # def include? element - @elements.include?(normalize element) + super(normalize element) end alias includes? include? + # - # Number of scopes - # - def size - @elements.size - end - # # returns a string representation in MOF syntax format # def to_s - "Scope(#{@elements.join(', ')})" + "Scope(#{self.join(', ')})" end private def normalize element element.downcase! if element.is_a?(String) e = element.to_sym - raise QualifierScopesError.new(element) unless META_ELEMENTS.include?(e) + raise QualifierScopeError.new(element) unless META_ELEMENTS.include?(e) e end end end