Sha256: dc0cabda5d05788cecfd9e075bfe03be36ef42d9098369784be3685dde40c905

Contents?: true

Size: 763 Bytes

Versions: 5

Compression:

Stored size: 763 Bytes

Contents

module Steep
  module Subtyping
    class Trace
      attr_reader :array

      def initialize(array: [])
        @array = array
      end

      def add(sup, sub)
        array << [sup, sub]
        yield
      ensure
        array.pop
      end

      def empty?
        array.empty?
      end

      def drop(n)
        self.class.new(array: array.drop(n))
      end

      def size
        array.size
      end

      def +(other)
        self.class.new(array: array + other.array)
      end

      def initialize_copy(source)
        @array = source.array.dup
      end

      def each
        if block_given?
          array.each do |pair|
            yield(*pair)
          end
        else
          enum_for :each
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
steep-0.11.1 lib/steep/subtyping/trace.rb
steep-0.11.0 lib/steep/subtyping/trace.rb
steep-0.10.0 lib/steep/subtyping/trace.rb
steep-0.9.0 lib/steep/subtyping/trace.rb
steep-0.8.2 lib/steep/subtyping/trace.rb