class Mentor::RubyErrorMain

Public Instance Methods

lines() click to toggle source
# File lib/sections/ruby_error_main.rb, line 7
def lines
  ruby_error_main
end

Private Instance Methods

bracketed_class() click to toggle source
# File lib/sections/ruby_error_main.rb, line 27
def bracketed_class
  "(#{ruby_error_class})"
end
does_not_fit_on_one_line?(part) click to toggle source
# File lib/sections/ruby_error_main.rb, line 61
def does_not_fit_on_one_line?(part)
  part.size >= terminal_width
end
fit_on_one_line?(part_a, part_b) click to toggle source
# File lib/sections/ruby_error_main.rb, line 57
def fit_on_one_line?(part_a, part_b)
  (part_a + ' ' + part_b).size <= terminal_width
end
fit_on_one_or_two_lines?(part_a, part_b) click to toggle source
# File lib/sections/ruby_error_main.rb, line 52
def fit_on_one_or_two_lines?(part_a, part_b)
  fit_on_one_line?(part_a, part_b) ||
    does_not_fit_on_one_line?(part_a) && fit_on_two_lines?(part_a, part_b)
end
fit_on_two_lines?(part_a, part_b) click to toggle source
# File lib/sections/ruby_error_main.rb, line 65
def fit_on_two_lines?(part_a, part_b)
  (part_a + ' ' + part_b).size <= terminal_width * 2
end
path_and_lineno() click to toggle source
# File lib/sections/ruby_error_main.rb, line 17
def path_and_lineno
  app_path_and_lineno = "#{app_dir}#{file_name}:#{error_lineno}:in `#{calling_method}':"

  if backtrace_lines.any?
    absolute_base_dir + app_path_and_lineno
  else
    app_path_and_lineno
  end
end
ruby_error_main() click to toggle source
# File lib/sections/ruby_error_main.rb, line 31
def ruby_error_main
  if single_line.size <= terminal_width
    [single_line]
  else
    ruby_error_wrapped
  end
end
ruby_error_wrapped() click to toggle source
# File lib/sections/ruby_error_main.rb, line 39
def ruby_error_wrapped
  if fit_on_one_or_two_lines?(path_and_lineno, message)
    [path_and_lineno + ' ' + message, bracketed_class]

  elsif fit_on_one_or_two_lines?(message, bracketed_class)
    [path_and_lineno, message + ' ' + bracketed_class]

  else
    [path_and_lineno, message, bracketed_class]

  end
end
single_line() click to toggle source
# File lib/sections/ruby_error_main.rb, line 13
def single_line
  [path_and_lineno, message, bracketed_class].flatten.join(' ')
end