Class: Debugger::EvalCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/eval.rb

Overview

:nodoc:

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, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ruby-debug/commands/eval.rb', line 56

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



52
53
54
# File 'lib/ruby-debug/commands/eval.rb', line 52

def help_command
  %w|p eval|
end

Instance Method Details

#executeObject



44
45
46
47
48
49
# File 'lib/ruby-debug/commands/eval.rb', line 44

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

#match(input) ⇒ Object



35
36
37
38
# File 'lib/ruby-debug/commands/eval.rb', line 35

def match(input)
  @input = input
  super
end

#regexpObject



40
41
42
# File 'lib/ruby-debug/commands/eval.rb', line 40

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