Class: Debugger::SetTypeCommand
- Defined in:
- lib/ruby-debug/commands/set_type.rb
Overview
Implements debugger “set_type” command
Constant Summary
Constants inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Command
commands, #find, inherited, #initialize, load_commands, #match, 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
38 39 40 41 42 43 44 |
# File 'lib/ruby-debug/commands/set_type.rb', line 38 def help(cmd) %{ set_type <var> <type> Change the type of <var> to <type> } end |
.help_command ⇒ Object
34 35 36 |
# File 'lib/ruby-debug/commands/set_type.rb', line 34 def help_command %w[set_type] end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby-debug/commands/set_type.rb', line 16 def execute if RUBY_VERSION < "1.9" print_msg "Not implemented" return end begin expr = @match[1] + " = " + @match[2] + "(" + @match[1] + ".inspect)" eval(expr) rescue begin expr = @match[1] + " = " + @match[2] + ".new(" + @match[1] + ".inspect)" eval(expr) rescue nil end end end |
#regexp ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/ruby-debug/commands/set_type.rb', line 7 def regexp / ^\s* set_type? \s* (?:\s+(\S+))?\s* (?:\s+(\S+))?\s* $ /ix end |