Class: Debugger::VarInstanceCommand
- Defined in:
- lib/ruby-debug/commands/variables.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Command
commands, 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
89 90 91 92 93 |
# File 'lib/ruby-debug/commands/variables.rb', line 89 def help(cmd) %{ v[ar] i[nstance] <object>\tshow instance variables of object, object can be given by its id or an expression } end |
.help_command ⇒ Object
85 86 87 |
# File 'lib/ruby-debug/commands/variables.rb', line 85 def help_command 'var' end |
Instance Method Details
#execute ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ruby-debug/commands/variables.rb', line 61 def execute if (@match[1]) obj = ObjectSpace._id2ref(@match[1].hex) rescue nil unless obj # TODO: ensure that empty variables frame will be printed @printer.print_msg("Unknown object id : %s", @match[1]) end else obj = debug_eval(@match.post_match) end return unless obj if (obj.class.name == "Array") then print_array(obj) elsif (obj.class.name == "Hash") then print_hash(obj) else b = obj.instance_eval{binding()} print_variables(obj.instance_variables, 'instance') do |var| debug_eval(var, b) end end end |
#regexp ⇒ Object
56 57 58 59 |
# File 'lib/ruby-debug/commands/variables.rb', line 56 def regexp # id will be read as first match, name as post match /^\s*v(?:ar)?\s+i(?:nstance)?\s+((?:[\\+-]0x)[\dabcdef]+)?/ end |