module Byebug::Helpers::VarHelper - byebug-11.0.1 Documentation

# module Byebug::Helpers::VarHelper

Utilities for variable subcommands

### Public Instance Methods

var_args() click to toggle source

    # File lib/byebug/helpers/var.rb, line 42
    def var_args
      args = context.frame.args
      return if args == [[:rest]]

      all_locals = context.frame.locals
      arg_values = args.map { |arg| arg[1] }

      locals = all_locals.select { |k, _| arg_values.include?(k) }
      puts prv(locals.keys.sort.map { |k| [k, locals[k]] }, "instance")
    end

var_global() click to toggle source

    # File lib/byebug/helpers/var.rb, line 21
    def var_global
      globals = global_variables.reject do |v|
        %i[$IGNORECASE $= $KCODE $-K $binding].include?(v)
      end

      var_list(globals)
    end

var_instance(str) click to toggle source

    # File lib/byebug/helpers/var.rb, line 29
    def var_instance(str)
      obj = warning_eval(str || "self")

      var_list(obj.instance_variables, obj.instance_eval { binding })
    end

var_list(ary, binding = context.frame._binding) click to toggle source

    # File lib/byebug/helpers/var.rb, line 13
    def var_list(ary, binding = context.frame._binding)
      vars = ary.sort.map do |name|
        [name, safe_inspect(silent_eval(name.to_s, binding))]
      end

      puts prv(vars, "instance")
    end

var_local() click to toggle source

    # File lib/byebug/helpers/var.rb, line 35
    def var_local
      locals = context.frame.locals
      cur_self = context.frame._self
      locals[:self] = cur_self unless cur_self.to_s == "main"
      puts prv(locals.keys.sort.map { |k| [k, locals[k]] }, "instance")
    end