Class: Byebug::EvalCommand

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

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, method_missing, options, #print_subcmds, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.help(cmd) ⇒ Object



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

def help(cmd)
  if cmd == 'p'
    %{
     p expression\tevaluate expression and print its value
     }
  else
    %{
     e[val] expression\tevaluate expression and print its value,
     \t\t\talias for p.
     * NOTE - to turn on autoeval, use 'set autoeval'
     }
  end
end

.help_commandObject



56
57
58
# File 'lib/byebug/commands/eval.rb', line 56

def help_command
  %w|p eval|
end

Instance Method Details

#executeObject



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

def execute
  expr = @match ? @match.post_match : @input
  run_with_binding do |b|
    print "#{debug_eval(expr, b).inspect}\n"
  end
end

#match(input) ⇒ Object



39
40
41
42
# File 'lib/byebug/commands/eval.rb', line 39

def match(input)
  @input = input
  super
end

#regexpObject



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

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