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

Constructor Details

This class inherits a constructor from Debugger::Command

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ruby-debug/commands/eval.rb', line 25

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.
    }
  end
end

.help_commandObject



21
22
23
# File 'lib/ruby-debug/commands/eval.rb', line 21

def help_command
  %w|p eval|
end

Instance Method Details

#executeObject



14
15
16
17
18
# File 'lib/ruby-debug/commands/eval.rb', line 14

def execute
  expr = @match ? @match.post_match : @input
  binding = @state.context ? get_binding : TOPLEVEL_BINDING
  print_eval expr, debug_eval(expr, binding).inspect
end

#match(input) ⇒ Object

self.control = true



5
6
7
8
# File 'lib/ruby-debug/commands/eval.rb', line 5

def match(input)
  @input = input
  super
end

#regexpObject



10
11
12
# File 'lib/ruby-debug/commands/eval.rb', line 10

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