Class: Byebug::PPCommand

Inherits:
Command show all
Defined in:
lib/byebug/commands/eval.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



77
78
79
# File 'lib/byebug/commands/eval.rb', line 77

def description
  %{pp expression\tevaluate expression and pretty-print its value}
end

.namesObject



73
74
75
# File 'lib/byebug/commands/eval.rb', line 73

def names
  %w(pp)
end

Instance Method Details

#executeObject



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/byebug/commands/eval.rb', line 58

def execute
  out = StringIO.new
  run_with_binding do |b|
    if Setting[:stack_on_error]
      PP.pp(bb_eval(@match.post_match, b), out)
    else
      PP.pp(bb_warning_eval(@match.post_match, b), out)
    end
  end
  print out.string
rescue
  out.puts $!.message
end

#regexpObject



54
55
56
# File 'lib/byebug/commands/eval.rb', line 54

def regexp
  /^\s* pp \s+/x
end