class Byebug::VarCommand::ConstCommand

Shows constants

Public Class Methods

description() click to toggle source
# File lib/byebug/commands/var/const.rb, line 20
def self.description
  <<-EOD
    v[ar] c[onstant]

    #{short_description}
  EOD
end
regexp() click to toggle source
# File lib/byebug/commands/var/const.rb, line 16
def self.regexp
  /^\s* c(?:onst)? (?:\s+ (.+))? \s*$/x
end
short_description() click to toggle source
# File lib/byebug/commands/var/const.rb, line 28
def self.short_description
  'Shows constants of an object.'
end

Public Instance Methods

execute() click to toggle source
# File lib/byebug/commands/var/const.rb, line 32
def execute
  obj = single_thread_eval(str_obj)
  unless obj.is_a?(Module)
    return errmsg(pr('variable.errors.not_module', object: str_obj))
  end

  constants = single_thread_eval("#{str_obj}.constants")
  puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, 'constant')
end

Private Instance Methods

str_obj() click to toggle source
# File lib/byebug/commands/var/const.rb, line 44
def str_obj
  @str_obj ||= @match[1] || 'self.class'
end