Class: Pry::Command::Cat::ExceptionFormatter

Inherits:
AbstractFormatter show all
Defined in:
lib/pry/commands/cat/exception_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::BaseHelpers

colorize_code, command_dependencies_met?, find_command, heading, highlight, jruby?, jruby_19?, mri?, mri_19?, mri_20?, mri_21?, mri_2?, not_a_real_file?, rbx?, #safe_send, safe_send, silence_warnings, stagger_output, use_ansi_codes?, windows?, windows_ansi?

Methods included from Helpers::CommandHelpers

absolute_index_number, absolute_index_range, command_error, get_method_or_raise, internal_binding?, one_index_number, one_index_range, one_index_range_or_number, restrict_to_lines, set_file_and_dir_locals, temp_file, unindent

Methods included from Helpers::OptionsHelpers

method_object, method_options

Constructor Details

#initialize(exception, _pry_, opts) ⇒ ExceptionFormatter


8
9
10
11
12
# File 'lib/pry/commands/cat/exception_formatter.rb', line 8

def initialize(exception, _pry_, opts)
  @ex = exception
  @opts = opts
  @_pry_ = _pry_
end

Instance Attribute Details

#_pry_Object (readonly)

Returns the value of attribute pry


6
7
8
# File 'lib/pry/commands/cat/exception_formatter.rb', line 6

def _pry_
  @_pry_
end

#exObject (readonly)

Returns the value of attribute ex


4
5
6
# File 'lib/pry/commands/cat/exception_formatter.rb', line 4

def ex
  @ex
end

#optsObject (readonly)

Returns the value of attribute opts


5
6
7
# File 'lib/pry/commands/cat/exception_formatter.rb', line 5

def opts
  @opts
end

Instance Method Details

#formatObject


14
15
16
17
18
19
20
21
# File 'lib/pry/commands/cat/exception_formatter.rb', line 14

def format
  check_for_errors
  set_file_and_dir_locals(backtrace_file, _pry_, _pry_.current_context)
  code = decorate(Pry::Code.from_file(backtrace_file).
                              between(*start_and_end_line_for_code_window).
                              with_marker(backtrace_line))
  "#{header}#{code}"
end