Class: Steep::Drivers::TracePrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/drivers/trace_printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ TracePrinter

Returns a new instance of TracePrinter.



6
7
8
# File 'lib/steep/drivers/trace_printer.rb', line 6

def initialize(io)
  @io = io
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



4
5
6
# File 'lib/steep/drivers/trace_printer.rb', line 4

def io
  @io
end

Instance Method Details



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/steep/drivers/trace_printer.rb', line 10

def print(trace, level: 0)
  trace.each.with_index do |t, i|
    prefix = " " * (i + level)
    case t[0]
    when :type
      io.puts "#{prefix}#{t[1]} <: #{t[2]}"
    when :method
      io.puts "#{prefix}(#{t[3]}) #{t[1]} <: #{t[2]}"
    when :method_type
      io.puts "#{prefix}#{t[1]} <: #{t[2]}"
    end
  end
end