Class: Steep::Subtyping::Trace
- Inherits:
-
Object
- Object
- Steep::Subtyping::Trace
- Defined in:
- lib/steep/subtyping/trace.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #add(sup, sub) ⇒ Object
- #drop(n) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(array: []) ⇒ Trace
constructor
A new instance of Trace.
- #initialize_copy(source) ⇒ Object
- #interface(sub, sup, &block) ⇒ Object
- #method(name, sub, sup, &block) ⇒ Object
- #method_type(name, sub, sup, &block) ⇒ Object
- #push(*xs) ⇒ Object
- #size ⇒ Object
- #type(sub, sup, &block) ⇒ Object
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
#array ⇒ Object (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
52 53 54 |
# File 'lib/steep/subtyping/trace.rb', line 52 def +(other) self.class.new(array: array + other.array) end |
#add(sup, sub) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/steep/subtyping/trace.rb', line 33 def add(sup, sub) array << [sup, sub] yield ensure array.pop end |
#drop(n) ⇒ Object
44 45 46 |
# File 'lib/steep/subtyping/trace.rb', line 44 def drop(n) self.class.new(array: array.drop(n)) end |
#each ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/steep/subtyping/trace.rb', line 60 def each if block_given? array.each do |pair| yield(*pair) end else enum_for :each end end |
#empty? ⇒ Boolean
40 41 42 |
# File 'lib/steep/subtyping/trace.rb', line 40 def empty? array.empty? end |
#initialize_copy(source) ⇒ Object
56 57 58 |
# File 'lib/steep/subtyping/trace.rb', line 56 def initialize_copy(source) @array = source.array.dup end |
#interface(sub, sup, &block) ⇒ Object
10 11 12 |
# File 'lib/steep/subtyping/trace.rb', line 10 def interface(sub, sup, &block) push :interface, sub, sup, &block end |
#method(name, sub, sup, &block) ⇒ Object
14 15 16 |
# File 'lib/steep/subtyping/trace.rb', line 14 def method(name, sub, sup, &block) push :method, sub, sup, name, &block end |
#method_type(name, sub, sup, &block) ⇒ Object
18 19 20 |
# File 'lib/steep/subtyping/trace.rb', line 18 def method_type(name, sub, sup, &block) push :method_type, sub, sup, name, &block end |
#push(*xs) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/steep/subtyping/trace.rb', line 26 def push(*xs) array << xs yield ensure array.pop end |
#size ⇒ Object
48 49 50 |
# File 'lib/steep/subtyping/trace.rb', line 48 def size array.size end |
#type(sub, sup, &block) ⇒ Object
22 23 24 |
# File 'lib/steep/subtyping/trace.rb', line 22 def type(sub, sup, &block) push :type, sub, sup, &block end |