Class: RubyJard::Screens::BacktraceScreen

Inherits:
RubyJard::Screen show all
Defined in:
lib/ruby_jard/screens/backtrace_screen.rb

Overview

Backtrace screen implements the content to display current thread’s backtrace to the user.

Instance Attribute Summary

Attributes inherited from RubyJard::Screen

#cursor, #layout, #rows, #selected, #window

Instance Method Summary collapse

Methods inherited from RubyJard::Screen

#click, #move_down, #move_up, #page_down, #page_up

Constructor Details

#initialize(*args) ⇒ BacktraceScreen

Returns a new instance of BacktraceScreen.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby_jard/screens/backtrace_screen.rb', line 8

def initialize(*args)
  super(*args)
  @current_frame = @session.current_frame
  @frames =
    @session
    .current_backtrace
    .select(&:visible?)
    .sort { |a, b| a.virtual_pos.to_i <=> b.virtual_pos.to_i }
  insert_current_frame
  @selected =
    if @current_frame.nil?
      0
    else
      @frames.find_index { |f| f.real_pos == @current_frame.real_pos }
    end
  @frames_count = @frames.length
  @hidden_frames_count = @session.current_backtrace.length - @frames.length

  @path_decorator = RubyJard::Decorators::PathDecorator.new
end

Instance Method Details

#buildObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ruby_jard/screens/backtrace_screen.rb', line 37

def build
  @rows = @frames.map do |frame|
    RubyJard::Row.new(
      line_limit: 2,
      columns: [
        RubyJard::Column.new(
          spans: [
            span_frame_pos(frame)
          ]
        ),
        RubyJard::Column.new(
          spans: [
            span_class_label(frame),
            span_label_preposition,
            span_method_label(frame),
            span_path(frame)
          ]
        )
      ]
    )
  end
end

#titleObject



29
30
31
32
33
34
35
# File 'lib/ruby_jard/screens/backtrace_screen.rb', line 29

def title
  if @hidden_frames_count <= 0
    ['Backtrace', "#{@frames_count} frames"]
  else
    ['Backtrace', "#{@frames_count} frames - #{@hidden_frames_count} hidden"]
  end
end