Class: Byebug::EvalCommand

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

Overview

Evaluation of expressions from byebug’s prompt.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



48
49
50
51
52
53
54
55
# File 'lib/byebug/commands/eval.rb', line 48

def description
  %{(p|e[val]) <expression>

    Evaluates <expression> and prints its value.

    * NOTE - unknown input is automatically evaluated, to turn this off
    use 'set noautoeval'.}
end

.namesObject



44
45
46
# File 'lib/byebug/commands/eval.rb', line 44

def names
  %w(p eval)
end

Instance Method Details

#executeObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/byebug/commands/eval.rb', line 30

def execute
  expr = @match ? @match.post_match : @input
  run_with_binding do |b|
    if Setting[:stack_on_error]
      puts "#{bb_eval(expr, b).inspect}"
    else
      puts "#{bb_warning_eval(expr, b).inspect}"
    end
  end
rescue
  puts "#{$ERROR_INFO.class} Exception: #{$ERROR_INFO.message}"
end

#match(input) ⇒ Object



21
22
23
24
# File 'lib/byebug/commands/eval.rb', line 21

def match(input)
  @input = input
  super
end

#regexpObject



26
27
28
# File 'lib/byebug/commands/eval.rb', line 26

def regexp
  /^\s* (p|e(?:val)?)\s+/x
end