Sha256: acdb10f934b8f89eb2cdffc3a7bbc36c0904bc7b58861b4a5d309db256cf7858

Contents?: true

Size: 681 Bytes

Versions: 5

Compression:

Stored size: 681 Bytes

Contents

module Alf
  module Engine
    class TypeSafe
      include Cog

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [TypeChecker] Type checker to use
      attr_reader :checker

      # Creates an Coerce instance
      def initialize(operand, checker, expr = nil, compiler = nil)
        super(expr, compiler)
        @operand = operand
        @checker = checker
      end

      # (see Cog#each)
      def _each
        @operand.each do |tuple|
          raise TypeCheckError, "Invalid tuple `#{tuple.inspect}`" unless checker===tuple
          yield(tuple)
        end
      end

    end # class TypeSafe
  end # module Engine
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/engine/type_safe.rb
alf-core-0.16.2 lib/alf/engine/type_safe.rb
alf-core-0.16.1 lib/alf/engine/type_safe.rb
alf-core-0.16.0 lib/alf/engine/type_safe.rb
alf-core-0.15.0 lib/alf/engine/type_safe.rb