Class: Byebug::VarConstantCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/byebug/commands/variables.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



80
81
82
# File 'lib/byebug/commands/variables.rb', line 80

def description
  %{v[ar] co[nst] <object>\t\tshow constants of object}
end

.namesObject



76
77
78
# File 'lib/byebug/commands/variables.rb', line 76

def names
  %w(var)
end

Instance Method Details

#executeObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/byebug/commands/variables.rb', line 60

def execute
  obj = bb_eval(@match.post_match)
  if obj.kind_of? Module
    constants = bb_eval("#{@match.post_match}.constants")
    constants.sort!
    for c in constants
      next if c =~ /SCRIPT/
      value = obj.const_get(c) rescue "ERROR: #{$!}"
      print " %s => %p\n", c, value
    end
  else
    print "Should be Class/Module: #{@match.post_match}\n"
  end
end

#regexpObject



56
57
58
# File 'lib/byebug/commands/variables.rb', line 56

def regexp
  /^\s* v(?:ar)? \s+ co(?:nst(?:ant)?)? \s+/x
end