Sha256: 43c8447726a9ec6c5fe9e2ee0e9fbeeca68b1a1e7ea48c3758c6281cd7b85184

Contents?: true

Size: 650 Bytes

Versions: 6

Compression:

Stored size: 650 Bytes

Contents

require 'singleton'
require_relative 'feature_domain'
require_relative 'identifier_value'

module Zenlish
  module Feature
    class IdentifierDomain < FeatureDomain
      include Singleton # Use the ingletion design pattern

      def build_value(aValue)
        IdentifierValue.new(validated_value(aValue))
      end
      
      def include?(aValue)
        aValue =~ /^[a-zA-Z\_][a-zA-Z0-9\_]*$/
      end

      private

      def validated_value(aValue)
        unless include?(aValue)
           raise StandardError, "#{aValue} isn't a valid identifier."
        end

        aValue
      end      
    end # class
  end # module
end # module

Version data entries

6 entries across 6 versions & 1 rubygems

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