Sha256: dbed2b534561e07f7477008e2351a6c65ffa0ebf0f380bf98cb2ece382251a7a

Contents?: true

Size: 762 Bytes

Versions: 11

Compression:

Stored size: 762 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

11 entries across 11 versions & 1 rubygems

Version Path
steep-0.8.1 lib/steep/subtyping/trace.rb
steep-0.8.0 lib/steep/subtyping/trace.rb
steep-0.7.1 lib/steep/subtyping/trace.rb
steep-0.7.0 lib/steep/subtyping/trace.rb
steep-0.6.0 lib/steep/subtyping/trace.rb
steep-0.5.1 lib/steep/subtyping/trace.rb
steep-0.5.0 lib/steep/subtyping/trace.rb
steep-0.4.0 lib/steep/subtyping/trace.rb
steep-0.3.0 lib/steep/subtyping/trace.rb
steep-0.2.0 lib/steep/subtyping/trace.rb
steep-0.1.0 lib/steep/subtyping/trace.rb