Module: Byebug::VarFunctions
- Defined in:
- lib/byebug/commands/variables.rb
Overview
Utilities for the var command.
Instance Method Summary collapse
- #var_class_self ⇒ Object
- #var_global ⇒ Object
- #var_instance(where) ⇒ Object
- #var_list(ary, b = get_binding) ⇒ Object
- #var_local ⇒ Object
Instance Method Details
#var_class_self ⇒ Object
24 25 26 27 |
# File 'lib/byebug/commands/variables.rb', line 24 def var_class_self obj = bb_eval('self') var_list(obj.class.class_variables, get_binding) end |
#var_global ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/byebug/commands/variables.rb', line 29 def var_global globals = global_variables.reject do |v| [:$IGNORECASE, :$=, :$KCODE, :$-K].include?(v) end var_list(globals) end |
#var_instance(where) ⇒ Object
37 38 39 40 |
# File 'lib/byebug/commands/variables.rb', line 37 def var_instance(where) obj = bb_eval(where) var_list(obj.instance_variables, obj.instance_eval { binding }) end |
#var_list(ary, b = get_binding) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/byebug/commands/variables.rb', line 6 def var_list(ary, b = get_binding) ary.sort! ary.each do |v| begin s = bb_eval(v.to_s, b).inspect rescue begin s = bb_eval(v.to_s, b).to_s rescue s = '*Error in evaluation*' end end s = "#{v} = #{s}" s[Setting[:width] - 3..-1] = '...' if s.size > Setting[:width] puts s end end |
#var_local ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/byebug/commands/variables.rb', line 42 def var_local _self = @state.context.frame_self(@state.frame_pos) locals = @state.context.frame_locals locals.keys.sort.each do |name| puts format(' %s => %p', name, locals[name]) end end |