Sha256: 99385f41294b0c32d3bc2f3faa1654c8690c4538b4e2d999ee79bca845b9c033

Contents?: true

Size: 653 Bytes

Versions: 5

Compression:

Stored size: 653 Bytes

Contents

require_relative 'feature_domain'
require_relative 'symbol_value'

module Zenlish
  module Feature
    class EnumerationDomain < FeatureDomain
      attr_reader :enum

      def initialize(*symbols)
        @enum = symbols
      end

      def build_value(aValue)
        SymbolValue.new(validated_value(aValue))
      end
      
      def include?(aValue)
        enum.include?(aValue)
      end

      private

      def validated_value(aValue)
        unless include?(aValue)
           raise StandardError, "#{aValue} isn't part of enumeration [#{enum.join(', ')}]."
        end

        aValue
      end
    end # class
  end # module
end # module

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zenlish-0.2.04 lib/zenlish/feature/enumeration_domain.rb
zenlish-0.2.03 lib/zenlish/feature/enumeration_domain.rb
zenlish-0.2.02 lib/zenlish/feature/enumeration_domain.rb
zenlish-0.2.01 lib/zenlish/feature/enumeration_domain.rb
zenlish-0.2.00 lib/zenlish/feature/enumeration_domain.rb