Module: Debugger::VarFunctions

Defined in:
lib/ruby-debug/commands/variables.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#var_class_selfObject



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

def var_class_self
  obj = debug_eval('self')
  var_list(obj.class.class_variables, get_binding)
end

#var_globalObject



25
26
27
# File 'lib/ruby-debug/commands/variables.rb', line 25

def var_global
  var_list(global_variables.reject { |v| [:$=, :$KCODE, :$-K].include?(v) })
end

#var_list(ary, b = get_binding) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ruby-debug/commands/variables.rb', line 3

def var_list(ary, b = get_binding)
  vars = ary.sort.map do |v|
    begin
      s = debug_eval(v.to_s, b).inspect
    rescue
      begin
        s = debug_eval(v.to_s, b).to_s
      rescue
        s = "*Error in evaluation*"
      end
    end
    if s.size > self.class.settings[:width]
      s[self.class.settings[:width]-3 .. -1] = "..."
    end
    [v, s]
  end
  print prv(vars, 'instance')
end