Class: Steep::Subtyping::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/subtyping/trace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array: []) ⇒ Trace

Returns a new instance of Trace.



6
7
8
# File 'lib/steep/subtyping/trace.rb', line 6

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

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



4
5
6
# File 'lib/steep/subtyping/trace.rb', line 4

def array
  @array
end

Instance Method Details

#+(other) ⇒ Object



29
30
31
# File 'lib/steep/subtyping/trace.rb', line 29

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

#add(sup, sub) ⇒ Object



10
11
12
13
14
15
# File 'lib/steep/subtyping/trace.rb', line 10

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

#drop(n) ⇒ Object



21
22
23
# File 'lib/steep/subtyping/trace.rb', line 21

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

#eachObject



37
38
39
40
41
42
43
44
45
# File 'lib/steep/subtyping/trace.rb', line 37

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

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/steep/subtyping/trace.rb', line 17

def empty?
  array.empty?
end

#initialize_copy(source) ⇒ Object



33
34
35
# File 'lib/steep/subtyping/trace.rb', line 33

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

#sizeObject



25
26
27
# File 'lib/steep/subtyping/trace.rb', line 25

def size
  array.size
end